Basic Linux commands that we used in day to day life

Basic Linux commands that we used in day to day life

  1. To view what's written in a file:

The cat command is used to check what's written in the file.

  1. To Change the Access Permissions of Files:

  1. To Check Which Commands You Have Run Till Now:

You can use the history command to check how many commands you've run till now

  1. To Remove a Directory/Folder:

rm : To remove the file

rmdir : to remove an empty folder/directory

rm -d : to remove an empty folder/directory

rm -r : to remove non-empty folder/directory

  1. To Create a Fruits.txt File and to View the Content:

touch : to create new file

vi filename : to edit the file( to add the contents in a file)

Please refer the below example:

Once you enter into the edit mode you'll have to follow the below steps:

a) enter i, then you can insert the text

b) enter esc after done with file updating

c) enter :wq! to save and quit from the file

  1. To Add Content in devops.txt (One in Each Line):

The echo command is used to add content to a file. For example, to add the words "Apple", "Mango", "Banana", "Cherry", "Kiwi", "Orange", and "Guava" to the file named devops.txt, one on each line, run the following commands:

  1. To Show Only the Top and last Three Fruits from the File:

The head command is used to display the first few lines of a file. For example, to show only the top three fruits from the devops.txt file, run the following command:

  1. To Show Only the Bottom Three Fruits from the File:

The tail command is used to display the last few lines of a file.

  1. To create another file Colors.txt and add content to it

Use echo to add content one by one and then use cat to see the content as shown in point no. 6)

  1. To find the difference between two files:

Use diff command to find the difference. Run the below command: