Essential Linux Commands with Unique Tips #Day-3
Table of contents
- View the content of a file and display line numbers:
- Change the access permissions of files to make them readable, writable, and executable by the owner only:
- Check the last 10 commands you have run:
- Remove a directory and all its contents:
- Create a fruits.txt file, add content (one fruit per line), and display the content:
- 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:
- Show the first three fruits from the file in reverse order:
- Show the bottom three fruits from the file, and then sort them alphabetically:
- Create another file Colors.txt, add content (one color per line), and display the content:
- Add content in Colors.txt (one in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey. Then, prepend "Yellow" to the beginning of the file:
- Find and display the lines that are common between myfruits.txt and Colors1.txt:
- Count the number of lines, words, and characters in both myfruits.txt and Colors1.txt:
- Conclusion
Linux commands are powerful tools that enable users to interact with the operating system efficiently. Here are some essential commands along with unique tips to make the most out of them:
View the content of a file and display line numbers:
nl filename
nl day3.txt
Change the access permissions of files to make them readable, writable, and executable by the owner only:
chmod 700 filename
chmod 700 day3.txt
Check the last 10 commands you have run:
history | tail -n 10
Remove a directory and all its contents:
rm -r directory_name
rm -r directory_name
Create a fruits.txt
file, add content (one fruit per line), and display the content:
echo -e "Kiwi\nWatermalon\nPinepal\nCherry\nGrep\nOrange" > myfruits.txt
cat myfruits.txt
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:
echo -e "Apple\nMango\nBanana\nCherry\nKiwi\nOrange\nGuava" > devops.txt
echo "Pineapple" >> devops.txt
Show the first three fruits from the file in reverse order:
head -n 3 myfruits.txt | tac
Show the bottom three fruits from the file, and then sort them alphabetically:
tail -n 3 myfruits.txt | sort
Create another file Colors.txt
, add content (one color per line), and display the content:
echo -e "Red\nPink\nWhite\nBlack\nBlue\nOrange\nPurple\nGrey" > Colors.txt
cat Colors.txt
Add content in Colors.txt
(one in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey. Then, prepend "Yellow" to the beginning of the file:
echo "Yellow" | cat Colors.txt > temp && mv temp Colors1.txt
cat Colors1.txt
Find and display the lines that are common between myfruits.txt
and Colors1.txt
:
comm -12 <(sort myfruits.txt) <(sort Colors1.txt)
Count the number of lines, words, and characters in both myfruits.txt
and Colors1.txt
:
wc myfruits.txt Colors1.txt
Conclusion
Mastering essential Linux commands can significantly enhance your efficiency and productivity when interacting with the operating system. By understanding and utilizing these commands, you can perform a wide range of tasks, from viewing and editing files to managing permissions and directories. The unique tips provided in this guide aim to help you leverage these commands to their fullest potential, making your Linux experience more streamlined and effective. Whether you are a beginner or an experienced user, these commands are fundamental tools that can simplify your workflow and improve your overall command-line proficiency.
Connect and Follow Me On Socials :
Like👍 | Share📲 | Comment💭
Subscribe to my newsletter
Read articles from Nikunj Vaishnav directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Nikunj Vaishnav
Nikunj Vaishnav
👋 Hi there! I'm Nikunj Vaishnav, a passionate QA engineer Cloud, and DevOps. I thrive on exploring new technologies and sharing my journey through code. From designing cloud infrastructures to ensuring software quality, I'm deeply involved in CI/CD pipelines, automated testing, and containerization with Docker. I'm always eager to grow in the ever-evolving fields of Software Testing, Cloud and DevOps. My goal is to simplify complex concepts, offer practical tips on automation and testing, and inspire others in the tech community. Let's connect, learn, and build high-quality software together! 📝 Check out my blog for tutorials and insights on cloud infrastructure, QA best practices, and DevOps. Feel free to reach out – I’m always open to discussions, collaborations, and feedback!