Now it's time to learn some basics to advance Linux commands!!🐧

Now it's time to learn some basics to advance Linux commands!!🐧

Β·

2 min read

It's a task of #day3

#90daysofDevOps challenge

  • To view what's written in a file?

    using the cat command you can able to reads data from the file and gives its content as output.

    • To change the access permissions of files

      using the chmod command you can change the access permission of a file.

      Permissions can be changed using two modes:

      i)Symbolic mode

      examples: chmod u+x file.txt

      ii)Numeric mode

      example: chmod 777 file.txt

    • To check which commands you have run till now

      history command is used to check the commands you have run till now.

      example:

    • To remove a directory/ Folder.

      To remove an empty directory, use the rmdir command.

      example:

      rmdir xyzfoldername

    • To remove a directory and all its contents, including any subdirectories and files use: rm

      example :

      rm -r xyzfoldername (it will remove the dir including the contents inside it)

  • To create a fruits.txt file and view the content.

    We are going to use the touch command to create the file and the cat command to view the content of the file

    touch fruits.txt

    echo "fruits are good for health" > fruits.txt

    cat fruits.txt

    fruits are good for health

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

    Add content to the fruits.txt file by using the vim editor

    vim fruits.txt

    Press i (insert)

    Apple

    Mango

    banana

    Cherry

    Esc(escape)

    :wq(write and quit that file)

  • Show only the top three fruits from the file.

    head -n 3 devops.txt

    Apple

    Mango

    Banana

  • Show only the bottom three fruits from the file.

    tail -n 3 devops.txt

    Kiwi

    Orange

    Guava

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

    touch Colors.txt

    "cat colors.txt"

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

    vim Colors.txt

    Red

    Pink

    White

    Black

    Blue

    Orange

    Purple

    Grey

    esc(enter escape)

    :wq( write and quit that file)

  • To find the difference between the fruits.txt and Colors.txt file

    To find the difference between the content of the two files we can use the diff command.
    eg
    diff fruits.txt Colors.txt

Thank you very much for giving your valuable time for reading this article !!☺😊

Arijit Manna

Β