Basic Linux Commands (Linux in Daily Routine)

Basic Linux Commands (Linux in Daily Routine)

Β·

3 min read

In this article, we'll explore fundamental Linux commands frequently used in everyday tasks involving Linux as the operating system.

πŸ“„ To view what's written in a file:

"cat" command is used to view the file

πŸ”’ To change the access permissions of files:

"chmod" command is used for changing file permission

πŸ“œ To check which commands you have run till now:

"history" command is used to view all the previous commands.

πŸ—‘οΈ To remove a directory/Folder

"rm -r" command means to remove recursively

πŸ“ To create a fruits.txt file and view the content:

"touch" command to create a file and "cat" command to view a file

To add content in devops.txt (One in each line) - 🍎Apple, πŸ₯­Mango, 🍌Banana, πŸ’ Cherry, πŸ₯ Kiwi, 🍊 Orange, 🍈 Guava

"echo -e 'text' > filename" '-e' is used to enable the '\n' interpretation and '\>' is redirection to a particular file to save the output

πŸ”Ό To Show only the top three fruits from the file:

"head -n" to show the desired number of lines in a file.

πŸ”½ To Show only the bottom three fruits from the file:

"tail -n" to show the desired number of lines in a file.

To create another file 🎨colors.txt and view the content:

"touch" command to create a file and "cat" command to view a file

To add content in 🎨colors.txt (One in each line) - πŸ”΄ Red, πŸ’— Pink, βšͺ White, ⚫ Black, πŸ”΅ Blue, 🟠 Orange, 🟣 Purple, 🌫️ Grey:

"echo -e 'text' > filename" '-e' is used to enable the '\n' interpretation and '\>' is redirection to a particular file to save the output

To find the πŸ”„ difference between fruits.txt & colors.txt file

"diff" command is used to show difference in file

1,5c1,5: This part of the output indicates that lines 1 to 5 in the first file have been changed to lines 1 to 5 in the second file. In other words, the lines from the first file are different from the lines in the second file.

The < symbol indicates the lines from the first file that are being changed.

The > symbol indicates the lines from the second file that replace the corresponding lines in the first file.

Let's interpret the changes based on the result:

  • Lines 1 to 5 in the first file (original file) contain the fruits "Apple," "Mango," "Banana," "Cherry," and "Kiwi."

  • Lines 1 to 5 in the second file (modified file) contain the colors "Red," "Pink," "White," "Black," and "Blue."

  • The first file originally had "Guava" on line 7, but it is not present in the second file.

  • The second file has added "Purple" and "Grey" on lines 7 and 8, respectively.

Β