Day 3 Task: Basic Linux Commands with a Twist

Mastering Basic Linux Commands: A Beginner's Guide π
Welcome to another exciting day of our DevOps journey! Today, we're diving into the essentials of Linux commands. Whether you're new to Linux or need a refresher, these commands will help you navigate and manipulate files like a pro. Let's get started! π»
Viewing the Content of a File with Line Numbers π
To view the content of a file and display line numbers, use the cat command with the -n option. This is handy for debugging or just keeping track of long files.

With -n you can view line number as well

Changing File Access Permissions π
To change file permissions so that only the owner can read, write, and execute, use the chmod command with 700:

Permissions are listed below:
| permission | on a file | on a directory |
| r (read) | read file content (cat) | read directory content (ls) |
| w (write) | change file content (vi) | create file in directory (touch) |
| x (execute) | execute the file | File permissions for (-rw-rw-r--) |
File permissions for (-rw-rw-r--)
| position | characters | ownership |
| 1 | - | denotes file type |
| 2-4 | rw- | permission for user |
| 5-7 | rw- | permission for group |
| 8-10 | r-- | permission for other |

Checking the Last 10 Commands π
To check the commands you have run, use the history command:

To check last 10 commands use tail -10

Removing a Directory and All Its Contents ποΈ
To remove a directory and all its contents, use the rm command with the -r (recursive) option:


Creating and Displaying a File with Fruits πππ
First, create a fruits.txt file and add content:

One way is to add each line manually as shown below :


Or else the best way to do it is using echo -e

Add content in devops.txt (one in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava. Then, append "Pineapple" to the end of the file.π

To append "Pineapple" to the end of the file:

Showing the First Three Fruits in Reverse Order π
To display the first three fruits in reverse order:

Displaying and Sorting the Bottom Three Fruits π
To display bottom 3 fruits you can use tail -3 fruits.txt

To show the bottom three fruits, then sort them alphabetically:

Creating and Displaying a Colors File π
First, create a Colors.txt file and add content:

To prepend "Yellow" to the beginning of the file:

Finding Common Lines Between Two Files π
To find and display lines that are common between fruits.txt and Colors.txt:

Counting Lines, Words, and Characters π
To count the number of lines, words, and characters in both fruits.txt and Colors.txt, use the wc command:

Conclusion
Linux commands are powerful tools that can significantly enhance your productivity. By mastering these basics, you're well on your way to becoming proficient in Linux, which is a crucial skill for any DevOps professional. Stay tuned as we continue our 90-day DevOps journey. Thereβs much more to learn and explore! π
Happy learning! πβ¨
Feel free to reach out with any questions or thoughts in the comments below. Happy DevOps-ing! π




