DEV Community

Kanav Gathe
Kanav Gathe

Posted on • Edited on

1

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!

Imagine monitoring actually built for developers

Billboard image

Join Vercel, CrowdStrike, and thousands of other teams that trust Checkly to streamline monitor creation and configuration with Monitoring as Code.

Start Monitoring

Top comments (1)

Collapse
 
devops_descent profile image
DevOps Descent

Interesting post.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay