Table of contents
- π To view what's written in a file:
- π To change the access permissions of files:
- π To check which commands you have run till now:
- ποΈ To remove a directory/Folder
- π To create a fruits.txt file and view the content:
- To add content in devops.txt (One in each line) - πApple, π₯Mango, πBanana, π Cherry, π₯ Kiwi, π Orange, π Guava
- πΌ To Show only the top three fruits from the file:
- π½ To Show only the bottom three fruits from the file:
- To create another file π¨colors.txt and view the content:
- To add content in π¨colors.txt (One in each line) - π΄ Red, π Pink, βͺ White, β« Black, π΅ Blue, π Orange, π£ Purple, π«οΈ Grey:
- To find the π difference between fruits.txt & colors.txt file
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.