Linux Commands and its use | #Day 3

Linux Commands and its use | #Day 3

  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:

command to view the contents of a file is 'cat'. The syntax is:

cat <filename>

Example :

  cat result.txt
  1. To change the access permissions of files:

    'chmod' command is used The syntax is:

      chmod <permissions> <filename>
    

    'permissions' refer to the new permissions you want to set, and can be specified using numbers or letters.

    Example :

         chmod 644 results.txt
    

    This command sets the read and write permissions for the owner, and read-only permission for the group and other user.

  2. To check which commands you have run till now:

    'history' command is use to check which commands you have run till now.

     history
    
  3. To remove a directory/ Folder.

     rm -rf Project
    
  4. To create a fruits.txt file and to view the content.

    Example :

      touch fruits.txt
    

    To view the contents of a file, you can use the 'cat' command.

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

    Example :

         echo "Apple" >> devops.txt
         echo "Mango" >> devops.txt
         echo "Banana" >> devops.txt
         echo "Cherry" >> devops.txt
         echo "Kiwi" >> devops.txt
         echo "Orange" >> devops.txt
         echo "Guava" >> devops.txt
    
  6. To Show only top three fruits from the file.

    "head" command is use to see number lins from a file.

         head -n <number of lines> <filename>
    

    Example :

      head -n 3 devops.txt
    

    this command will display the first 3 fruits in the 'devops.txt' file.

  7. To Show only bottom three fruits from the file. : 'tail' command is use

       tail -n <number of lines> <filename>
    

    Example :

       tail -n 3 devops.txt
    

    This command will display the last 3 fruits in the 'devops.txt' file.

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

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

    1.      echo "Red" >> colours.txt
           echo "Pink" >> colours.txt
           echo "White" >> colours.txt
           echo "Black" >> colours.txt
           echo "Blue" >> colours.txt
           echo "Orange" >> colours.txt
           echo "Purple" >> colours.txt
           echo "Gray" >> colours.txt
      
  10. To find the difference between fruits.txt and colors.txt file.

  11.      diff fruits.txt colors.txt