Showing posts with label commands. Show all posts
Showing posts with label commands. Show all posts

Tuesday, February 28, 2017

Linux Commands

Commands:

1.cd(Change Directory):
cd                               :for home directory
cd name of directory :will move the control to that directory
cd ..                            :move out of the current directory
cd ../..                         :move out two times of the current directory

2.ls:

ls                                :List the contents of current Directory
ls -a                            :List all the files including hidden files

Example of cd and ls:


3.pwd(Print Working Directory):

pwd                            :print the current working directory
Example:


4.man : command is used for getting details of any command

Example:
5. mkdir : command is used for making a directory/folder in the current directory

Example:
6.rm : command is used for deletion of a file
   rmdir: command is used for deletion of a directory/folder
   rm -r: command is used for deletion of a non empty folder/directory
Example:
7.history: command is used to check all the previous commands used
Example:

8.whoami: command is used to find username
9. uname: command reports basic information about computer hardware and software
Example:

10.top: top command is used to see the currently running  processes with ram usage
Example:

11.gedit:  gedit is used to create a file
Syntax : gedit file name
Example:
12.touch: this command is used to create an empty file
Syntax: touch filename
Example:
13.cat : cat command is used to show the comments of any file in terminal
Example:
this command can also be used to create a file

Syntax:  cat > file name   (Replace the previous contents)
              cat >> file name (append the file)
Example:
14.vi : this command is used to create a file in terminal using vi editor
Syntax: vi filename
Example:
In Vi Editor First Press i To Start Writing
Then For Ending Press ESC key the use any of following
:wq - for closing and saving file
:q!-   for closing without saving
:w-    for saving only

15.cp : command is used to copy file
Syntax: cp source file destination file
Example:
16.mv : command is used to move one file to another location
Syntax: mv source destination
 Can also be used for renaming a file
Example:
17.diff : this command is used to find difference between two files
Syntax: diff file1 file2
Example:



This command also tells how to make two files identical

c - change the contents
a - append the contents
d - delete the contents

18.more:  this command is used to view the contents of file
      Syntax: more filename

19.head :  this command is used to view the first 10 lines of file
       Syntax: head filename
Here we can also specify the no of lines required
            For ex: head -3 filename will print three first lines

20. tail  :   this command is used to view the last 10 lines of file

In this we can also specify the no of lines
            For ex: tail -3 filename   will view the last three lines

Example:
21. df  :  this command is used to view the memory available and used by various drives
            for ex : df -h
-h for Human readable format
we can also specify ant particular drive to get info about that only.

22. du : this command is used to get the memory occupied by a particular directory with a list of all subdirectories.

For ex :  du -sh Directory
Here s for simple only Directory no subdirectory listing,h for human readable

Example:
 23. lsblk: this command print all block devices all tell the type of device

Example:
 24. htop: htop command is used to view the currently running processes of the particular user

Example: