DevOps (Day -3)

Linux(Solving Questions)

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

    We can use the "cat" command to view the contents of the file.

    cat <path_of_file>

  2. To change the access permissions of files.

    The permission for any file or directory goes like this:-

    drwxrwxrwx <username> <groupname> <filename>

    d-> Directory.

    The first set of rwx -> User permission.

    The second set of rwx -> Group permission.

    The third set of rwx -> Other permission.

    chmod <permission that varies from 000 to 777> <filename>

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

    "history"

    1. To remove a directory/ Folder.

      rm <filename>

      rmdir <foldername>

      -r:- can be used to delete recursively in a folder.

      -f:- Delete forcefully.

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

    touch book.txt

    cat book.txt

    1. Add content in book.txt (One in each line) - Ramayana, Mahabharat, Geeta , Srimadbhagwatgeeta.

      Contents are added using Vim editor.

      vim book.txt

    2. Show only the top two books from the file.

      head -n <filename>

      n:- the line number from starting of the file.

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

        touch Colors.txt

        cat Colors.txt

      2. Add content in Colors.txt (One in each line) - Red, Pink, White, Black

        Using Vim <filename> to edit the file.

        1. To find the difference between the book.txt and Colors.txt files.

          diff <file1> <file2>

          sdiff <file1> <file2>

          -a: add

          -c: change

          -d: delete