Home > Linux / Unix > Linux basic commands with examples

Linux basic commands with examples

linux basic commands with examples

Linux basic commands with examples


Today we are going to study some frequently use Linux basic commands with examples which are helpful for beginner and advanced level Linux admin and shell programmer.

Note: All Linux commands are case sensitive and must be typed in Lowercase Letter (a b,c…).

Below are the list of Linux basic commands with examples :

  1. pwd : Use to see Present Working Directory. 
  2. cd : Use to Change Directory.
  3. mkdir : Use to Make Directory.
  4. rmdir : Use to Remove Directory (But Directory should be empty ).
  5. ls : Use to List out files and directory present inside the present directory.
  6. touch : Use to Create a new file.
  7. vi : Use to edit or modify file data also use to create new file as well.
  8. cat : Use to see file data in the same console / Windows.
  9. rm : Use to remove file. 
  10. rm -r : Use to remove directory along with files and other directories which are inside.

Linux basic commands with examples


  • Command : pwd
  1. Use to see Present Working Directory. 
  2. In the below snap when we type “pwd” command in the console then we can able to see the present working directory of root user is “/root also “~” .Linux basic commands with examplesTo learn more about cd command, read: cd command in Linux

  • Command: cd
  1. Use to Change Directory.
  2. In the below snap when we type “cd” command along with directory name ” T4Tution ” which is present in this directory (/root) then it will switch to T4Tution or /root/T4Tution directory from /root directory .Linux basic commands with examples

Below command, use to go back to multiple directory. As we can see before we are in “d3” directory and after the mentioned command “cd ./../../ ” executed we go back of two directories in “d1“.


  • Command: mkdir
  1. Use to Make Directory.
  2. When we type “mkdir” along with directory name.
    It creates a new directory as mentioned in a snap ” mkdir T4Tution “. mkdir commands create new directory “T4Tution” in /root.

In below snap when we type commands ” mkdir -p d1/d2/d3 “.
It creates directory and subdirectory at the same time, that means first it create d1 after that it create d2 inside d1 and d3 inside d2.

In above snap when we type command mkdir along with directories name as mentioned “mkdir dir1 dir2 dir3” in above snap then it creates multiple directories.


  • Command: rmdir

rmdir” use to remove /delete an empty directory.


  • Command: ls
  1.  Use to List out files and directory present inside a present directory.
  2. ls” command list out all directory and file in given directory.

Below command ls -l” gives complete information about file and directory.

“ls -la” command display  hidden files and directory.


  • Command: touch
  1. Use to Create a new file.
  2. Below command “touch” along with file name used to create a new file.

We can create multiple files by using touch command as shown above.


  • Command: vi
  1. Use to edit or modify file data also use to create a new file as well.
  2. Below command “vi” along with file name used to create a new file and to edit a file as well.

Once we have done with editing then we can save by :wq (w means to save and q means quite ).


  • Command: cat
  1. Use to see file data in same console.Below command used to display data of a file.

  • Command: rm 
  1. Use to remove the file. 
  2. rm command uses to remove file or files by user permission. “y” means yes and “n” means no.

When we try to execute above command, “rmdir d1″ then it will show error as we can see but when we execute “rm -r” then this command remove complete directory and file by user permission.


 

Admin
We are group of application developer and admin.We are providing good content of information about IT technology and services .

Leave a Reply

Your email address will not be published. Required fields are marked *