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
2. Change File Permissions
chmod 700 filename # Only owner can read, write, execute
# OR
chmod u+rwx,go-rwx filename
3. View Command History
history | tail -n 10
4. Remove Directory
rm -rf directory_name
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
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
7. Display First Three Fruits in Reverse
head -n 3 fruits.txt | tac
8. Sort Bottom Three Fruits
tail -n 3 fruits.txt | sort
9. Create Colors.txt
cat << EOF > Colors.txt
Red
Pink
White
Black
Blue
Orange
Purple
Grey
EOF
10. Add Yellow to Colors.txt
echo "Yellow" | cat - Colors.txt > temp && mv temp Colors.txt
11. Find Common Lines
comm -12 <(sort fruits.txt) <(sort Colors.txt)
12. Count Lines, Words, and Characters
wc fruits.txt Colors.txt
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!