Sunteți pe pagina 1din 8

2/16/12

Uni b Rahul Singh

A co
Home S llab Li of Book A ignmen

e on Uni /Lin
Welcome o he command line
Mo ing a o nd he FileS em
Commands for moving around the file system include the following: pwd: The pwd command will allow you to know the directory in which you're located (pwd stands for "print working directory"). cd: The cd command will allow you to change directories. When you open a terminal you will be in your home directory. To move around the file system you will use cd. For example, cd /Desktop will move you to your desktop directory. To navigate into the root directory, use cd / To navigate to your home directory, use cd To navigate up one directory level, use cd .. To navigate to the previous directory (or back), use cd To navigate through multiple levels of directory at once, use cd / var/www for example, which will take you directly to the /www subdirectory of /var/.

---------------------UNIX OS ---------------------Gene al O e ie

In od c ion o ke nel The B ffe Cache ---------------------Shell P og amming ---------------------Uni Shell Command

Manip la ing File and Folde


You can manipulate files and folders using the following commands:
uni b rahul.50 ebs.com/shell1.html 1/8

2/16/12

Uni b Rahul Singh

cp: The cp command will make a copy of a file for you. For example, cp file foo will make an exact copy of file and name it "foo," but the file "file" will still be there. When you use mv, that file would no longer exist, but when you use cp the file stays and a new copy is made. mv: The mv command will move a file to a different location or will rename a file. Examples are as follows: mv file foo will rename the file "file" to "foo." mv foo /Desktop will move the file "foo" to your desktop directory but will not rename it. You must specify a new file name to rename a file. To save on typing, you can substitute in place of the home directory. Note: If you are using mv with sudo you will not be able to use the shortcut. Instead, you will have to use the full pathnames to your files. rm: Use this command to remove or delete a file in your directory. It will not work on directories in which there are files. ls: The ls command will show you the files in your current directory. Used with certain options, you can see file sizes, when files were created, and file permissions. For example, ls will show you the files that are in your home directory. mkdir: The mkdir command will allow you to create directories. For example, mkdir music will create a music directory. chmod: The chmod command will change the permissions on the files listed. Permissions are based on a fairly simple model. You can set permissions for user, group, and world, and you can set whether each can read, write, and execute the file. For an example, if a file had permission to allow everybody to read but only the user could write, the permissions would read rwxr-r-. To add or remove a permission, you append a + or a - in front of the specific permission. For example, to add the capability for the group to edit in the previous example, you could type chmod g+x file. chown: The chown command allows the user to change the user and group
uni b rahul.50 ebs.com/shell1.html 2/8

2/16/12

Uni b Rahul Singh

ownerships of a file. For example, chown jim file would change the ownership of the file to"Jim."

S stem Information Commands


System information commands include the following: df: The df command displays filesystem disk space usage for all partitions. The command df-h is probably the most useful. It uses megabytes (M) and gigabytes (G) instead of blocks to report. (-h means "human-readable.") free: The free command displays the amount of free and used memory in the system. For example, free -m will give the information using megabytes, which is probably most useful for current computers. top: The top command displays information on your Linux system, running processes, and system resources, including the CPU, RAM, swap usage, and total number of tasks being run. To exit top, press Q. uname -a: The uname command with the a option prints all system information, including machine name, kernel name, version, and a few other details. Most useful for checking which kernel you're using. lsb_release -a: The lsb_release command with the -a option prints version information for the Linux release you're running. For example: user@computer: $ lsb_release -a LSB Version: n/a Distributor ID: Ubuntu Description: Ubuntu (The Breezy Badger Release) Release: Codename: breezy ifconfig: This reports on your system's network interfaces. iwconfig: The command iwconfig will show you any wireless network adapters and the wireless specific information from them, such as speed and network connected.
uni b rahul.50 ebs.com/shell1.html 3/8

2/16/12

Uni b Rahul Singh

p : The command p allo o o ie he p oce e nning on he machine.

all

The follo ing command li he ha d a e on o comp e , ei he a pecific pe o i ha pecific me hod. The a e mo ef l fo deb gging hen a piece of ha d a e doe no f nc ion co ec l . l pci: The command l pci li all PCI b e and de ice connec ed o hem. Thi commonl incl de ne o k ca d and o nd ca d . l b: The command l b li all USB b e and an connec ed USB de ice , ch a p in e and h mb d i e . l hal: The command l hal li all de ice he ha d a e ab ac ion la e (HAL) kno abo , hich ho ld be mo ha d a e on o em. l h : The command l h li ha d a e on o em, incl ding make , pe, and he e i i connec ed.

Searching and Editing Te t Files


Sea ch and edi command : e file ing he follo ing

g ep: The command g ep allo o o ea ch in ide a n mbe of file fo a pa ic la ea ch pa e n and hen p in ma ching line . Fo e ample, g ep blah file ill ea ch fo he e "blah" in he file and hen p in an ma ching line . ed: The ed (o S eam EDi o ) command allo ea ch and eplace of a pa ic la ing in a file. Fo e ample, if o an ed o find he ing "ca " and eplace i i h "dog" in a file named pe , o o ld pe ed /ca /dog/g. ca : The ca command, ho fo conca ena e, i ef l fo ie ing and adding o e file . The imple ca FILENAME ill di pla he con en of he file. U ing ca filename file add he con en of he fi file o he econd. nano: Nano i a imple e edi o fo he command line. To open a file, e nano filename. Command li ed a he bo om of he c een a e acce ed ia c l+le e
uni b rahul.50 ebs.com/shell1.html 4/8

2/16/12

Uni b Rahul Singh

name. less: The less command is used for viewing text files as well as standard output. A common usage is to pipe another command through less to be able to see all the output, such as ls less.

Dealing

ith Users and Groups

You can use the following commands to administer users and groups: adduser: The adduser command will create a new user. To simply create a new user, type sudo adduser $loginname. This will create the user's home directory and default group. It will prompt for a user password and then further details about the user. passwd: The passwd command will change the user's password. If simply run by a regular user, it will change his password. If run using sudo, it can change any user's password. For example, sudo passwd joe will change Joe's password. who: The who command will tell you who is currently logged into the machine. addgroup: The addgroup command will add a new group. To create a new group, type sudo addgroup $groupname. deluser: The deluser command will remove a user from the system. To remove their files and home directory, you need to add the -remove-home option delgroup: The delgroup command will remove a group from the system. You cannot remove a group that is the primary group of any users.

Getting Help on the Command Line


This section will provide you with some tips on getting help on the command line. The commands -help and man are the two most important tools at the command line. Virtually all commands understand the -h (or help) option which will produce a short usage description of the command and its options, then exit back to the command prompt. Try man -h or man -help to see this in action.
uni b rahul.50 ebs.com/shell1.html 5/8

2/16/12

Uni b Rahul Singh

E e c a d a d ea e e a ica i i Li i ha e a a ( a a ) fi e, fi di g he i a i e a i g a c a d bi g a ge a a e f he ecified c a d. F e a e, a i bi g he (M e) a a . S e he f i f i g he a c a d i c de: a e :M e a dd he a fi e i g he a e . : Q i bac he c a d b i g . a a : a a i bi g he a a e f he a c a d, hich i a g d ace a ! a i : a i i e ecia ef . I di a he I d c i U e C a d , hich i a e - i e , fai b ief i d c i he Li c a d i e. The e a e a i f age , hich a e ge e a e i -de h ha a age . T i f i f f he i d c i i f age .

Using Wildcards
S e i e eed a e i e fi e a he a e i e. F i a ce, igh a de e e a . a fi e e a . d fi e a he di ec . Tha f , he e a e e ie f i dca d ca e ac i h hi . * i a ch a be f cha ac e . F e a e, *. a i a ch a fi e i h he e di g f . a *? i a ch a i g e cha ac e . F e a e, ?. a i a ch a. a b ab. a * [cha ac e ] i a ch a f he cha ac e i hi he b ac e . F e a e, [ab]. a i a ch a. a a d b. a b c. a * [!cha ac e ] i a ch a cha ac e ha a e i ed. F e a e, [!ab]. a i a ch c. a b a. a b. a .

E ecuting Multiple Commands


uni b rahul.50 ebs.com/shell1.html 6/8

2/16/12

Uni b Rahul Singh

Often you may want to execute several commands together, either one after another or by passing output from one to another. Run Sequentiall If you need to execute multiple commands in sequence, but don't need to pass output between them, you can run them using ; between each command. Each command will be executed, and the following command will be run. If you want to make the running of the second command conditional on the successful completion of the first command, separate the commands with &&. If you need to execute multiple commands in sequence, but don't need to pass output between them, there are two options based on whether or not you want the subsequent commands to run only if the previous commands succeed or not. If you want the commands to run one after the other regardless of whether or not preceding commands succeed, place a ; between the commands. For example, if you want to get information about your hardware, you could run lspci ; lsusb, which would output information on your PCI buses and USB devices in sequence. However, if you need to conditionally run the commands based on whether the previous command has succeeded, insert && between commands. An example of this is building a program from source, which is traditionally done with ./configure, make, and make install. The commands make and make install require that the previous commands have completed successfully, so you would use ./configure && make && make install. Passing Output If you need to pass the output of one command so that it goes to the input of the next, you need something called piping after the character used between the commands, , which looks like a vertical bar or pipe. To use the pipe, insert the between each command. For example, using the in the
uni b rahul.50 ebs.com/shell1.html 7/8

2/16/12

Uni b Rahul Singh

command ls less allows you to view the contents of the ls more easily.

Created by:- Rahul Singh

uni b rahul.50 ebs.com/shell1.html

8/8

S-ar putea să vă placă și