#90DaysOfDevOps - Day 3: Linux basic commands continued...
π DevOps Enthusiast | Continuous Learner | Bridging Development & Operations | Automating for Efficiency ππ€π | Exploring the Ever-Evolving Tech Landscape | Passionate about Collaboration & Innovation | Let's Build, Deploy, and Soar Together! π»π οΈπ
Introduction
Welcome to Day 3 of #90DaysOfDevOps! Today, we continue learning the next set of Linux basic commands on various file operations like create, delete, add contents, compare between files, and change file permissions. These tasks are essential for DevOps operations.
Tasks
Remove a directory/folder:
Create and delete a directory named "temp" from your current location.

We start by creating
day3folder usingmkdir. Usemkdirto createtempdirectory,temp/file1.txtfile,temp/subdirdirectory, andtemp/subdir/file1.txtfile. Usetreecommand to confirm the directory structure. Usermwith-roption to remove the entire temp directory recursively. Usetreecommand to confirm.Create a new file:
Create a file named "fruits.txt".

Use
touchcommand to create the filefruits.txt.Add content to a file and view its content:
Open the "fruits.txt" file (if it exists) and add the following fruits, one on each line:
Apple
Mango
Banana
Cherry
Kiwi
Orange
Guava

Use
touchcommand to createfruits.txtfile. Useechowith-eoption and direct the output>to thefruits.txtfile.echois command to print on the terminal. With-eoption\nis treated as newline character. This is why we see the contents being added line by line. Usecatcommand to display the contents offruits.txtfile.Show the top three fruits from a file:
Display only the top three fruits from the "fruits.txt" file.

Use
headcommand with-nand number of lines i.e.3option to display the first three lines offruits.txtfile.Show the bottom three fruits from a file:
Display only the bottom three fruits from the "fruits.txt" file.

Use
tailcommand with-nand number of lines i.e.3option to display the last three lines offruits.txtfile.Change the access permissions of a file:
Modify the permissions of the "fruits.txt" file so that only the owner can read and write to it.

Use
lscommand to check the current file permissions offruits.txt. We see that thefruits.txtfile has owner read and write access, group read and write access, others read only access (-rw-rw-r--). Usechmodwithg-rwto remove group read and write access,o-rto remove others read only access. Uselscommand to verify. We see that thefruits.txtfile now only has owner read and write access (-rw-------)This same thing can be done by using chmod with 600.

Create another file and view its content:
Create a file named "colors.txt" and add the following content:
Red
Pink
White
Black
Blue
Orange
Purple
Grey

Perform this task as explained in Task 3.
Find the difference between the two files:
Determine the differences between the "fruits.txt" and "Colors.txt" files.

Use
diffcommand to display the differences betweenfruits.txtandcolors.txtfiles. It displays what changes needs to be done to thefruits.txtfile to match the contents ofcolors.txtfile.1,5c1,5denotes that lines 1 to 5 of fruits.txt file need to be changed to match lines 1 to 5 of the colors.txt file.Check command history:
View a list of commands you have run previously in the terminal.

Use
historycommand to get the list of commands that were executed until now.
Conclusion
π Congratulations! π Today, you've conquered Day 3 of #90DaysOfDevOps! π You've mastered various essential Linux commands like:
π touch (to create files)
π history (to check command history)
π cat (to view file contents)
π head (to show the top of a file)
π tail (to display the end of a file)
π chmod (to change file permissions)
π diff (to find differences between files)
Keep up the fantastic work! πͺ Stay committed and keep on leveling up your DevOps skills! π
"π± Keep learning, and spread the knowledge to inspire others. ππ‘"