Day 3 : DevOps ❤️

Let's Discuss some more questions on Linux

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

     cat file_name
    
    1. Change the access permissions of files to make them readable, writable, and executable by the owner only.
    chmod 700 file_name

permission_code :

  1. Read: 4

  2. Write: 2

  3. Execute: 1

\=> Users:Groups: Others

For Ex: chmod 700 file.sh

The above command means that users have all the 3 permissions (i.e. read, write, execute) on the other hand groups, and others have no permissions.

  1. Check the last 10 commands you have run.

     history | tail -n 10
    
  2. To remove a directory/ Folder

     rm -r folder_name
    

    -r = recursively (used if the folder is not empty)

  3. Create a fruits.txt file, add content (one fruit per line), and display the content.

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

     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
    
  5. Show the first three fruits from the file in reverse order.

     head -n 3 devops.txt | tac
    
  6. Show the bottom three fruits from the file, and then sort them alphabetically.

     tail -n 3 devops.txt | sort
    
  7. Create another file Colors.txt, add content (one color per line), and display the content.

     touch Colors.txt
     cat Colors.txt
    
  8. Add content in Colors.txt (one in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey. Then, prepend "Yellow" to the beginning of the file.

    echo "Yellow" | cat - devops.txt > temp && mv temp devops.txt
    
  9. Find and display the lines that are common between fruits.txt and Colors.txt.

    sort file1.txt -o fruits.txt
    sort file2.txt -o Colors.txt
    comm -12 fruits.txt fruits.txt
    
  10. Count the number of lines, words, and characters in both fruits.txt and Colors.txt.

    wc fruits.txt
    wc Colors.txt
    

Cute Bye GIFs | Tenor