Day3, 90 Days of Devops Challenge

·

3 min read

Table of contents

No heading

No headings in the article.

Task: 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. To Show only top three fruits from the file.

  8. To Show only 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, Grey.

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

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

    The 'cat' command can be used to display the content of a file.

    syntax: cat <filename>

  2. To change the access permissions of file.

    Linux chmod command is used to change the access permissions of files and directories. It stands for change mode.

    syntax: chmod <options> <permissions> <file name\>

    1. ex. Following “chmod” command will give the user permission to read, write and execute a file

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

Linux history command is used to display the history of the commands executed by the user. It is a handy tool for auditing the executed commands along with their date and time.

syntax: history

  1. To remove a directory/ Folder.

rmdir command is used to delete a directory. But will not be able to delete a directory including a sub-directory. It means, a directory has to be empty to be deleted.

  1. To create a file and view its content

    vim command is used to create a file.

    syntax: vim fruits.txt

    cat command is used to view the content in the file.

  2. Create a devops.txt file and add content on each line

    Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava

    syntax: vim devops.txt

    after executing this command file gets created and opened in editor.

    Now enter the fruits name in each line.

  3. To view top three lines of devops.txt file

    syntax: head -3 devops.txt

  4. To see last three lines of devops.txt file

    syntax: tail -3 devops.txt

  5. Create a new file colors.txt using echo command and add content in it

    while creating the file.

    syntax : echo "Yellow,Red,Blue">colors.txt

    Now to view the content use cat commnd nas below.

    syntax: cat colors.txt

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

    syntax: vi colors.txt then hit 'i' to insert data in file.

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

    diff stands for difference. This command is used to display the differences in the files by comparing the files line by line

    syntax: diff Colors.txt fruits.txt