#90daysOfDevops

Day 3 Task: Basic Linux Commands

Task: What is the linux command to

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

    cat filename

  2. To change the access permissions of files.

    chmod 777 filename

Permission | Provide permission
read | add 4
write | add 2
execute | add 1

Permissions are revoked using subtraction
Permission | Provide permission
read | subtract 4
write | subtract 2
execute | subtract 1

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

    history

    i)To view history one page at a time, you can use the following:
    history | less
    ii)To view just the last ten commands, you can use the following:
    history | tail
    iii)To view the last 25 commands, just use the following:
    history 25

  2. To remove a directory/ Folder.

    rm filename

    rmdir folder,directory

Once these command are run to remove file or directory it can't be restore

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


    echo Happy learning >> fruits.txt
    cat fruits.txt

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

    **echo Apple>> fruits.txt

    echo Mango\>> fruits.txt

    echo Banana\>> fruits.txt

    echo cherry\>> fruits.txt
    **

  3. To Show only top three fruits from the file.
    The Linux head command prints the first lines of one or more files (or piped data) to standard output. By default, it shows the first 10 lines.

  4. To Show only bottom three fruits from the file.

    To display the last part of the file, we use the tail command in the Linux system. The tail command is used to display the end of a text file or piped data in the Linux operating system. By default, it displays the last 10 lines of its input to the standard output. It is also complementary of the head command.

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

    File can be created with touch command and view using cat command

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

    echo Red >> Colors.txt

    echo Pink >> Colors.txt

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

    we can use diff command.
    eg
    diff fruits.txt Colors.txt