DEV Community

Kanav Gathe
Kanav Gathe

Posted on

Day 3/90: Basic Linux Commands with a Twist 🐧 #90DaysOfDevOps

Day 3: Basic Linux Commands with a Twist 🚀

Hello DevOps enthusiasts! 👋 Welcome to Day 3 of the #90DaysOfDevOps challenge. Today, we're exploring file operations and content manipulation in Linux.

Task Solutions 📝

1. View File Content with Line Numbers

cat -n filename.txt
# OR
nl filename.txt
Enter fullscreen mode Exit fullscreen mode

2. Change File Permissions

chmod 700 filename    # Only owner can read, write, execute
# OR
chmod u+rwx,go-rwx filename
Enter fullscreen mode Exit fullscreen mode

3. View Command History

history | tail -n 10
Enter fullscreen mode Exit fullscreen mode

4. Remove Directory

rm -rf directory_name
Enter fullscreen mode Exit fullscreen mode

5. Create and Display fruits.txt

# Create file with content
cat << EOF > fruits.txt
Apple
Mango
Banana
Cherry
Kiwi
Orange
Guava
EOF

cat fruits.txt
Enter fullscreen mode Exit fullscreen mode

6. Manipulate devops.txt

# Create file with content
cat << EOF > devops.txt
Apple
Mango
Banana
Cherry
Kiwi
Orange
Guava
EOF

# Append Pineapple
echo "Pineapple" >> devops.txt
Enter fullscreen mode Exit fullscreen mode

7. Display First Three Fruits in Reverse

head -n 3 fruits.txt | tac
Enter fullscreen mode Exit fullscreen mode

8. Sort Bottom Three Fruits

tail -n 3 fruits.txt | sort
Enter fullscreen mode Exit fullscreen mode

9. Create Colors.txt

cat << EOF > Colors.txt
Red
Pink
White
Black
Blue
Orange
Purple
Grey
EOF
Enter fullscreen mode Exit fullscreen mode

10. Add Yellow to Colors.txt

echo "Yellow" | cat - Colors.txt > temp && mv temp Colors.txt
Enter fullscreen mode Exit fullscreen mode

11. Find Common Lines

comm -12 <(sort fruits.txt) <(sort Colors.txt)
Enter fullscreen mode Exit fullscreen mode

12. Count Lines, Words, and Characters

wc fruits.txt Colors.txt
Enter fullscreen mode Exit fullscreen mode

Key Takeaways 💡

  • File content can be viewed and manipulated in various ways
  • Permissions control access to files and directories
  • Text processing commands are powerful for file manipulation
  • Command history helps track your actions

Linux #DevOps #Technology #Learning #90DaysOfDevOps


This is Day 3 of my #90DaysOfDevOps journey. Stay tuned for more DevOps learning!

Top comments (0)