Skip to main content

Command Palette

Search for a command to run...

Basic Linux Commands (Linux in Daily Routine)

Published
โ€ข3 min read
Basic Linux Commands (Linux in Daily Routine)
A

AWS Devops | Linux | Docker | Jenkins | Terraform | Kubernetes | Ansible |

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.

More from this blog

Getting Started with Devops

15 posts