#Day3: Basic Linux Commands - Part2

#Day3: Basic Linux Commands - Part2

Lets start with #Day3 Task............... #Linux #90daysofdevops

ยท

3 min read

Table of contents

No heading

No headings in the article.

What is the Linux command to:

  1. To view what's written in a file.

  2. To change the access permissions of files.

  3. To check which commands you have run till now.

  4. To remove a directory/ Folder.

  5. To create a fruits.txt file and to view the content.

  6. Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.

  7. Show only the top three fruits from the file.

  8. Show only the bottom three fruits from the file.

  9. To create another file Colors.txt and to view the content.

  10. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, and Grey.

  11. To find the difference between the fruits.txt and Colors.txt files.

  1. how to view what's written in a file?

    In Linux, if we want to see content in the file then we need to use the cat command.

    Syntax: cat <options><filname>

    e.g. cat my_file.txt

    e.g cat -n my_file.txt

    if we use cat -n my_file.txt show output with line numbers.

    e.g cat my_file.txt > my_file1.txt

  2. How to change the access permissions of files.

    e.g chmod 751 my_file1.txt

    The above table is the access permissions table for chmod

    with the help of this we can easily change the permission for file/directory.

  3. How to check which commands you have run till now?

  4. To remove a directory/ Folder?

    eg.:- rm -r devops/

  5. To create a fruits.txt file and to view the content.

touch fruits_1.txt echo "Mango" >> fruits_1.txt echo "watermelon" >> fruits_1.txt

echo "Apple" >> fruits_1.txt

cat fruits_1.txt

  1. Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.

    to add content to a file we can use the above method

    using echo command to write one line method to add a string in the file, But that is an efficient way to write content instead of that we can use Vim editor.

    we will see that with an example refer below Screenshot and the commands.

    touch devops.txt
    vim devops.txt

  2. How to view only the top three fruits from the file?

    to view the top 3 lines we need to use the head command with option -3 and filename.

    • By default, the head command shows the top 10 lines.

  1. Show only the bottom three fruits from the file.

    To view the bottom 3 lines we need to use the tail command with option -3 and filename.

    • By default, the tail command shows the bottom 10 lines.

  2. To create another file Colors.txt and to view the content.

    use touch command for creating a file to see the content of a file using the cat command.

  3. Add content in Colors.txt (One in each line) - Red, Pink,
    touch colors.txt

    echo "Red" >> Colors.txt

    echo "Pink" >> Colors.txt

    echo "White" >> Colors.txt

    echo "Black" >> Colors.txt

    echo "Blue" >> Colors.txt

    echo "Orange" >> Colors.txt

    echo "Purple" >> Colors.txt

    echo "Grey" >> Colors.txt

    cat colors.txt

  4. To find the difference between the fruits.txt and Colors.txt files.

    the the diff command is used to see the difference between the two files by comparing the files line by line.

    eg. diff <file1> <file2>

Thank you for taking out your valuable time to read this blog.๐Ÿ™Œ๐Ÿ™Œ๐Ÿ™‚

I hope it will help you. :)

๐Ÿ‘‰ https://www.linkedin.com/in/ankush-aglawe/
You can follow me on LinkedIn for my Daily Updates.

๐Ÿ‘‰https://twitter.com/ankush738937704
You can follow me on Twitter.

Shubham Londhe #trainwithshubham #devops #Linux #90daysofdevops #Day3 #Day3/90day

THANK YOU!!!!!

ย