Day 3 Task: Basic Linux Commands

Day 3 Task: Basic Linux Commands

ยท

3 min read

This is #90DaysofDevops challenge under the guidance of Shubham Londhe sir.

Day 3 TASK

Are you ready to dive into the world of Linux commands? Let's explore some fundamental commands that every Linux user should know.

  1. Viewing the Contents of a File: To see what's written in a file, you can use the cat command. For example:

     cat filename.txt
    

  2. Changing File Access Permissions: To modify the access permissions of files, you can use the chmod command. For instance:

     chmod 700 filename
    

    • The first digit (7) indicates that the owner of the file (supriya.txt) has full permissions, meaning they can read, write, and execute the file.

    • The second digit (0) indicates that the group owner of the file does not have any permissions.

    • The third digit (0) indicates that other users (not the owner or in the group) also do not have any permissions.

    • So, in simple terms, the command chmod 700 supriya.txt grants the owner of the file supriya.txt full control over the file, while denying any access to the group owner and other users.

    • This ensures that only the owner has the ability to read from, write to, and execute the supriya.txt file.

  1. Checking Command History: To review the commands you've executed previously, simply type:

     history
    

  2. Removing a Directory/Folder: To delete a directory, use the rmdir command. Be cautious, as it removes empty directories.

     rmdir directory_name
    

  3. Creating and Viewing a File: To create a file named fruits.txt and view its content, execute:

     touch fruits.txt
     cat fruits.txt
    

  4. Adding Content to a File: To add content to the devops.txt file, one item per line, you can use a text editor like nano or simply append with echo:

     echo -e "Apple\nMango\nBanana\nCherry\nKiwi\nOrange\nGuava" > devops.txt
    

  5. Displaying Top Three Fruits: To display only the top three fruits from the file, you can use the head command:

     head -n 3 devops.txt
    

  6. Showing Bottom Three Fruits: To show only the bottom three fruits from the file, utilize the tail command:

     tail -n 3 devops.txt
    

  7. Creating and Viewing Another File: Create a file named Colors.txt and view its content:

     touch Colors.txt
     cat Colors.txt
    

  8. Adding Content to Colors.txt: Add colors to the Colors.txt file, one per line:

    echo -e "Red\nPink\nWhite\nBlack\nBlue\nOrange\nPurple\nGrey" > Colors.txt
    

  9. Finding Differences Between Files: To identify the differences between fruits.txt and Colors.txt, use the diff command:

    diff fruits.txt Colors.txt
    

  • These Linux commands form the foundation of your journey into the world of Linux.

If you found this post useful, please consider giving it a follow and tapping the clap ๐Ÿ‘ button to let us know! Your support means a lot.

Thank you for taking the time to read! ๐Ÿ’š

ย