Basic Linux Commands

Passionate about Python, Cloud Computing, and DevOps. Architecting robust cloud solutions, mastering AWS & Azure, and automating with cutting-edge DevOps tools. Join me on this journey of innovation and collaboration. Let's shape the future together!
π Welcome back to our ongoing series on mastering Linux commands! In today's session, we will delve into some fundamental commands that will enhance your proficiency in navigating and manipulating files and directories. By the end of this tutorial, you'll be equipped with the knowledge to view file contents, change file permissions, remove directories, create files, and more. Let's get started! πͺπ
π Here are the commands we will cover: β¨
π View file contents ποΈ
To view the contents of a file, you can use the cat command. It displays the entire contents of a file. π
- Example:
cat file.txtπ
π Change access permissions of files π
To control who can read, write, or execute a file, use the chmod command. It allows you to change file permissions. π‘οΈ
- Example:
chmod u+rw file.txtπ
π Check command history β°
To view the list of commands you have executed, use the history command. It displays a numbered list of previously executed commands. π
- Example:
historyπ
π Remove a directory/folder ποΈ
To remove an empty directory, use the rmdir command. To remove a directory with its contents, use rm -r. β»οΈ
Example (empty directory):
rmdir myfolderπExample (directory with contents):
rm -r myfolderποΈ
π Create a file and view its content π
To create a file, use the touch command. To view its content, use the cat command. π
Example (create):
touch fruits.txtβοΈExample (view content):
cat fruits.txtπ
π Add content to devops.txt β
To add content to a file, use the echo command with the >> operator. Each echo command adds a new line. βοΈ
Example:
echo "Apple" >> devops.txtπecho "Mango" >> devops.txtπ₯echo "Banana" >> devops.txtπ...
π Show top three fruits from the file π₯
To display the top three fruits from a file, use the head command with the -n option. π
- Example:
head -n 3 devops.txtπ
π Show bottom three fruits from the file π₯
To view the bottom three fruits from a file, use the tail command with the -n option. π
- Example:
tail -n 3 devops.txtπ
π Create another file and view its content π
To create a file, use the touch command. To view its content, use the cat command. π
Example (create):
touch Colors.txtπExample (view content):
cat Colors.txtπ
π Add content to Colors.txt β
To add content to a file, use the echo command with the >> operator. Each echo command adds a new line. βοΈ
Example:
echo "Red" >> Colors.txtπ΄echo "Pink" >> Colors.txtπecho "White" >> Colors.txtβͺ
π Find the difference between fruits.txt and Colors.txt π
π To compare the contents of two files, use the diff command. π
- Example:
diff fruits.txt Colors.txtπ
Conclusion π
In a world of Linux commands, we embarked on a thrilling journey filled with π knowledge and π empowerment! From peering into file contents with ποΈ to granting them fortresses of π permissions, we danced through directories, leaving no clutter behind. With the stroke of a virtual brush, files bloomed to life, sharing their tales through π echoes of fruit and color. We crowned the top three π₯ and discovered the depths of the bottom three π₯, adding flavor to our command creations. And as we compared files with the π lens of "diff," we unveiled the secrets they held. Now, armed with π‘οΈ emojis and boundless enthusiasm, we march forth, ready to conquer new Linux realms! πͺπ§
π’ Stay in the βοΈ cloud loop and blast off into the π DevOps universe! Join me on Hashnode, where I share my latest insights and articles about all things cloud and DevOps. Let's connect on LinkedIn (https://www.linkedin.com/in/nirmal-mahale-605565215/) and explore the boundless possibilities of the tech cosmos together. π And hey, if you want to peek under the hood of my projects, hop on over to my GitHub (https://github.com/nirmal7030). π οΈ
π Your support and engagement mean the π to me. Together, let's dive deeper into the world of cloud βοΈ, soar to new heights with DevOps π, and make a positive impact in the tech universe. Thank you for reading and joining me on this exciting journey! πβ¨




