Support lwplabs

Sep 15, 20231 min

Linux for DevOps Interview Questions

  1. Question: Write a Linux command to list all files and directories in the current directory.
     
    Answer: ls
     

  2. Question: How would you create a new directory named "my_project" in the home directory of the current user?
     
    Answer: mkdir ~/my_project
     

  3. Question: Write a command to display the contents of a text file named "example.txt" on the terminal.
     
    Answer: cat example.txt
     

  4. Question: How can you move a file named "file.txt" from the current directory to a directory named "destination"?
     
    Answer: mv file.txt destination/
     

  5. Question: Write a command to copy a directory and its contents ("my_folder") from one location to another, preserving permissions and timestamps.
     
    Answer: cp -r my_folder/ destination/
     

  6. Question: How would you remove a file named "obsolete.txt" from the current directory?
     
    Answer: rm obsolete.txt
     

  7. Question: Write a command to list all running processes on the system.
     
    Answer: ps aux
     

  8. Question: How can you find all files in the current directory and its subdirectories with the ".log" file extension?
     
    Answer: find . -name "*.log"
     

  9. Question: Write a command to check the disk space usage of all mounted filesystems.
     
    Answer: df -h
     

  10. Question: How would you archive a directory named "my_data" into a compressed tarball named "my_data.tar.gz"?
     
    Answer: tar -czvf my_data.tar.gz my_data/

    590
    0