l inux c ommand l ine i nterface 15-09-2013 g unaanban.g [email protected]

58
LINUX COMMAND LINE INTERFACE 15-09-2013 GUNAANBAN.G [email protected]

Upload: anastasia-ryan

Post on 24-Dec-2015

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

LINUX

COMMAND LINE INTERFACE

15-09-2013

GUNAANBAN.G

[email protected]

Page 2: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

What is Command Line Interface in Linux? Actually it’s a terminal. Which is a command prompt

in Windows.

Two kind of terminals are there. They are,

Terminal Emulator GUI (Alt+Ctrl+T)

Text Based terminal (Alt+Ctrl+F1 / F2 / F3 / F4 / F5 /

F6)

“ / ” - represents ‘or’

Page 3: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Text based terminal can be used by six or less no. of users at a time.

While entering into each terminal it will ask for user name and password to identify particular user.

Same user can work on different terminals at a time.

To exit from terminal to Graphical User Interface the below shortcut key is used

“ Alt+Ctrl+F7 ”

Page 4: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

COMMANDS Starting with the basic Command “man ”

‘man ’ represents Manual.

This command used to give the instructions about the command.

Page 5: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

For example, man sudo command gives the instructions about sudo command.

Page 6: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command “dir “

‘ dir ‘ stands for directory. It is used to display the files and folders within that directory.

It displays file with its extension.

Page 7: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ mkdir “

‘ mkdir ‘ stands for make directory. This command is used to create a directory. The syntax is,

mkdir foldername

Page 8: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command –”rmdir”

“rmdir” stands for remove directory. This is used to remove the directory. Make sure that the directory should be empty. The syntax is,

rmdir directory_name

Page 9: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command -“ ls “

It displays a list of files in the current directory in alphabetical order. It also differentiate the file name using colors with respect to their permissions.

This command can be used with some options like “ls –a” and

“ls –l ” .

Command ls –a : ( It displays all directory including hidden files)

Page 10: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command ls –l :It displays all directory and files along with their user access

permissions.

Page 11: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “clear”

“clear” command is used to clean the screen of the terminal window. Before clearing,

After clearing the screen,

Page 12: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command - “ cd “

It is used to change the directory. ‘ cd ‘ stands for change directory. Example given below as cd gisak.

The command “cd . “ is used to stay on the same directory.

The command “ cd .. “ is used to go back to the previous directory.

The command “ cd ” is also used to redirect to the home directory.

Page 13: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ pwd “

‘ pwd ‘ stands for print working directory. It is used to display the path of current working directory. The syntax is ,

pwd

Page 14: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command –”date”

“date” command is used to display the current system date and time.

Page 15: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “cat”

‘ cat ’ command is used to create a file. The syntax is cat > filename

“ text here “Ctrl + d

Example is,

Page 16: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command –”sh”

“ sh” command is used to run the program in the file. The syntax is , sh file_name

Page 17: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ mv “

‘ mv ‘ command is used to rename the file and also move a file from one directory to another. The syntax for renaming a file ,

mv old_name new_name

Page 18: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

‘ mv ‘ command used for moving files. The syntax is ,

mv path1/file path2/

Page 19: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

‘ cat ‘ command is used to view the content of the file. The syntax is ,

cat filename

‘ cat ‘ command also used to concatenate two files and redirect the output to another file. The syntax is ,

cat file1 file2 > outputfile

Page 20: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ cmp”

‘ cmp ‘ command is used to display the difference between the contents of the two files. The syntax is ,

cmp file1 file2

In the above example, the output shows that, “ the variation starts from the sixth character(byte 6) in the first line(line 1) ”.

Page 21: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ diff ”

‘ diff ‘ command is used to give the changes in the files while copying one directory to another. It have three different ways in describing difference between the files. They are,

Changed to , Addition to , Deleted to.

The syntax is,diff original_file copied_file

Page 22: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

In the above output, 3c1 says that 3 line changed to a single line while copying the file. 1c1 says that 1 line is changed upto 3 line.

Page 23: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

In the above output, 1a2 says that 1st line is equal and addition to 2 and 3 lines.

In the above output, 3d1 says that 2nd and 3rd line are deleted while copying the file.

Page 24: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ cp “

‘ cp ‘ stands for copy. This command is used to copy the content of the one file to another file. The syntax is ,

cp source_file destination_file

Page 25: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ wc “

‘ wc ‘ stands for word count. It is used to count the content of the file. The syntax is ,

wc filename

‘ wc –l ‘ is used to display no. of line in the file. ‘ wc –c ‘ is used to display no. of characters in the file. ‘ wc –w ‘ is used to display no. of words in the file.

Page 26: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command –” find “

“find” command used to search a file with some constraints. The syntax is,

find <option> <size_value>

Page 27: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ more “

‘ more ‘ command is used display the large content file in the terminal window by percentage basis. The syntax is,

more filename

The percentage based examples for more command is given below.

Page 28: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com
Page 29: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com
Page 30: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com
Page 31: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Just click enter to see next line… Finally it automatically return to normal window…. It can be stopped by clicking ‘ Ctrl+z ‘.

Page 32: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “sort” ‘ sort ‘ command is used to display the content of the file in

ascending order. The syntax is,

sort filename

Page 33: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

‘ sort –b ‘ command ignores the blank space and displays the content of the file in ascending order. The syntax is ,

sort –b filename

Page 34: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ greb “

‘ greb ‘ command is used to display the same content in 2 different files. The syntax is,

greb file1 file2

Page 35: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ paste “

‘ paste ‘ command is used to combine two various file contents. The syntax is,

paste file1 file2

Page 36: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – ” vi “

‘ vi ‘ command used to open a file using Command Line Editor.

Page 37: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

We can edit the file by clicking the ‘insert’ button on the keyboard. After editing the file, click the ‘insert’ button again.

After changing text in the file, save the file and exit. enter “ :wq “.

Page 38: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

To discard the changes and exit the file, enter “ :q “.

Page 39: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Make sure that the file has the permission to write….. Otherwise below output will be shown.

Page 40: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ rm “

‘ rm ‘ command is used to delete a file. The syntax is,rm filename

Page 41: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ whoami “

‘ whoami ‘ command is used to show the current login user name. The syntax is,

whoami

Page 42: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ su ” ‘ su ‘ stands for super user. It is used for login from one user to another. More

likely log off method.

‘ su –l’ command is used for switch user login to root login. Then it ask for root password.

To come back to normal use the command ‘ logout ‘.

Page 43: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ who “

‘ who ‘ command is used to display the login users with their terminal details. The syntax is,

who

Page 44: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ chmod “

‘ chmod ‘ stands for change mode. This command is used to change the file permissions. This command offers symbolic and numerical way for changing the modes. The syntax is ,

chmod <group> <operation> <mode> filename

Page 45: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

File before changing the permissions.

Page 46: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Restricting the reading and writting permission of the file in numerical way.

Page 47: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Opening the file, after restricting the permissions.

Page 48: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Providing permissions to the file in numerical way.

Removing permissions of the file in symbolic way.

Page 49: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Providing permissions to the file in symbolic way.

In changing the group, it has 3 types. They are,User , Group , Other.

In Operations ,it also has 3 types . They are, + , - , =

In changing the modes, it also has 3 types. They are,read(4) , write(2) , and execute(1)

Page 50: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ | “

‘ | ‘ is a pipeline command. It is used to join 2 commands.

It displays 4 users are working on different terminals at the same time.

Page 51: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ wall “

‘ wall ‘ command is used to display messages to all the users on different terminals at a same time. The syntax is ,

wall

Sender side…

Receiver side….

Page 52: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – ” adduser “

‘ adduser ‘ command is used to add a new user to the system. The syntax is,

adduser username

Page 53: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ passwd “

‘ passwd ‘ command used to change the password of the user. The syntax is,

passwd username

Page 54: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command – “ userdel “

‘ userdel ‘ command is used to delete the user id. The Syntax is ,userdel username

Page 55: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command –”sudo passwd root”

‘sudo passwd root’ command is used to change the passwd of the root from the user by using super user facility. In this user must have the administrator permissions. Guest users are not allowed to change this.

Page 56: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command –”shutdown”

“shutdown” command is used to halt or stop all the system processes. The syntax is,

shutdown <option> <time> “shutdown –r now” command is used to restart the computer.

“shutdown –h now” command is used to shutdown or suspend the computer.

The Admin user “root” can only use this commands.

Page 57: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Command –”init”

‘init’ command is also used in halting the system performance.The syntax is,

init <option>

“init 0” Command is used to shutdown or suspend the computer.

This command is also only used by the root user.

Page 58: L INUX C OMMAND L INE I NTERFACE 15-09-2013 G UNAANBAN.G gunaanban@gmail.com

Thank you