DEV Community

Udoh Deborah
Udoh Deborah

Posted on

Day 3 - Mastering Linux Commands

In DevOps, Linux isn't just an operating system — it's the backbone of cloud infrastructure, automation, and deployment.

The task for day 3 simply explains the intricacies of creating files, setting permissions, manipulating content etc.,
but here's why it really matters:

  • Security
    Understanding file permissions (chmod, chown) ensures that only the right users have access. This is critical for protecting sensitive data and preventing system breaches.

  • Automation & Scripting
    Commands like cat, echo, head, tail, and sort are the building blocks of automation. Mastering them means you can write shell scripts to manage systems, process logs, and deploy code at scale.

  • Data Manipulation
    Working with files — reading, writing, appending, sorting — is a core part of system administration. These commands make you efficient and effective at handling real-world data.

  • Foundation for Advanced Tools
    Whether it’s Docker, Kubernetes, Ansible, or Jenkins — they all rely on Linux environments. Understanding how to operate confidently in the terminal is essential for working with these tools.

Task Linux Command
1. View the content of a file and display line numbers cat -n filename.txt or nl filename.txt
2. Make file readable, writable, executable by owner only chmod 700 filename.txt
3. Check the last 10 commands you have run `history tail -10`
4. Remove a directory and all its contents rm -r directory_name
5. Create fruits.txt, add content (one fruit per line), and display it
cat > fruits.txt
Apple
Mango
Banana
Cherry
Kiwi
Orange
Guava
<Ctrl + D>

cat fruits.txt
6. Create devops.txt and append “Pineapple”
cat > devops.txt
Apple
Mango
Banana
Cherry
Kiwi
Orange
Guava
<Ctrl + D>

echo "Pineapple" >> devops.txt
7. Show the first three fruits in reverse order `head -n 3 devops.txt tac`
8. Show the bottom three fruits and sort alphabetically `tail -n 3 devops.txt \ sort`
9. Create Colors.txt, add one color per line, and display it
cat > Colors.txt
Red
Pink
White
Black
Blue
Orange
Purple
Grey
<Ctrl + D>

cat Colors.txt
10. Prepend "Yellow" to the beginning of Colors.txt sed -i '1iYellow' Colors.txt
11. Find and display common lines between both files comm -12 <(sort fruits.txt) <(sort Colors.txt)
12. Count lines, words, and characters in both files wc fruits.txt Colors.txt

Linux commands turn you from a user into a power user. Capable of automating, optimizing, and managing systems like a pro.

Bottom line: These basics command lines can empower you to build, secure, and automate systems — the core of every modern DevOps role.

Top comments (0)