Skip to main content

Command Palette

Search for a command to run...

#90daysOfDevops day 03

In this article, we discuss different Linux commands related to a file. Like changing the permissions of a file, printing each word on a new line, etc

Updated
2 min read
#90daysOfDevops day 03

Day 3 Task: Basic Linux Commands

Task: What is the linux command to

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

    cat = it is the command to view what is written in the file .

  2. To change the access permissions of files.

    So first we check the file permission by ls -l command of v1.txt file then we change the permission of this file. So here we can see that v1.txt file owner has only read and write permission.now we will change the file permission by the command

    Syntax: chmod [permission][filename]

    chmod 700 v1.txt ------ 7 is used read,write and execute.

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

    history is used to check all the command which we run till now.

  4. To remove a directory/ Folder.

    *if you want to delete each folder and file in rich dir then use r {recursively} and also want to display the additional message that directory is removed or not use v(verbose).

    *To remove files without prompting, even if the files are write-protected, pass the -f (force) option to the rm command:

    *we can also use rm - r command to remove file/folder

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

    cat command is also used to create a new file . and view the content

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

    cat > devops.txt is th command in which you can add each fruit in new line.

    You can also echo Command:

    echo -e "Apple\nMango\nBanana\nCherry\nKiwi\nOrange\nGuava" > devops.txt

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

    we can use head command to display the top 3 fruits from the devops.txt file

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

    Tail is used to show the bottom three fruits of the devops.txt file .

    tail -3 devops.txt

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

    We can use touch command to create the file color.txt file. touch command is used to create empty file .

    [ ] $ touch color.txt

    To view the content the command is

    [ ]$ cat color.txt

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

    we can also echo and vim command to display the color in each line

    Command:

    echo -e "Red\nPink\nWhite\nBlack\nBlue\nOrange\nPurple\nGrey" > Colors.txt

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

    diff command is used to find the difference between two file