Basic Linux Commands

Basic Linux Commands

#Day3 of #90daysofdevops Challenge

What is the Linux command to

  • Which command is used to view what's written in the file?

      cat file_name
    

  • Which command is used to change the access permissions of files?

      chmod <options> file_name
          eg: chmod 777 test1.txt 
          eg: chmod u+rwx test1.txt
    

  • Which command is used to check which commands you have run till now?

      history
    

  • Which command is used to remove a directory/ Folder?

      rmdir directory_name
      rm -r directory_name
    

  • List the commands to create a fruits.txt file and view the content of it.

    --> For creating the fruits.txt file we have several ways like touch and cat. and for viewing the contents we can use cat with the file name.

      # for creating the file .
      touch fruits.txt
      cat > fruits.txt
      # for veawing the contents of the files.
      cat fruits.txt
    

  • Write the commands to add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.

      cat > file_name
    

  • Write the commands to show only the top three fruits from the file.

      head -n file_name
      # here "n" is basically number of lines .
    

  • Write the commands to show only the bottom three fruits from the file.

      tail -n file_name
      # here "n" is basically number of lines .
    

  • Write the commands to add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple,Grey.

    --> If we are using vim editor then write "vim file_name" into cmd then press enter. after entering into vim editor now press " i " key to enable input mode. after content writing press :wq for save and exit from the vim editor.

       vim file_name   # press enter
    

  • How To find the difference between fruits.txt and Colors.txt files.

      diff  file_name1 file_name2
    

So , This was my task from #90daysofdevops Challenge initiated by #trainwithshubham.

Thank you for the reading.