Skip to main content

Command Palette

Search for a command to run...

Basic Linux Commands

Updated
β€’4 min readβ€’View as Markdown
Basic Linux Commands
N

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! πŸŽ‰βœ¨

More from this blog

DevOpsPythonic

14 posts