Linux for DevOps Interview Questions
- Support lwplabs
- Sep 14, 2023
- 1 min read
Question: Write a Linux command to list all files and directories in the current directory. Answer: ls
Question: How would you create a new directory named "my_project" in the home directory of the current user? Answer: mkdir ~/my_project
Question: Write a command to display the contents of a text file named "example.txt" on the terminal. Answer: cat example.txt
Question: How can you move a file named "file.txt" from the current directory to a directory named "destination"? Answer: mv file.txt destination/
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/
Question: How would you remove a file named "obsolete.txt" from the current directory? Answer: rm obsolete.txt
Question: Write a command to list all running processes on the system. Answer: ps aux
Question: How can you find all files in the current directory and its subdirectories with the ".log" file extension? Answer: find . -name "*.log"
Question: Write a command to check the disk space usage of all mounted filesystems. Answer: df -h
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/
Comments