010-160 Linux Command Line & Shell Scripting — Questions and Answers
Question 1: Which command is used to display the contents of a directory in Linux?
- ls (Correct answer)
- dir
- cd
- pwd
Correct answer: ls
The `ls` command (list) is a fundamental utility in Linux used to display the contents of a directory. By default, it lists files and subdirectories within the current working directory. Various options can be used with `ls` to provide more detailed information, such as file permissions, ownership, and modification dates.
Question 2: What is the primary purpose of shell scripting in Linux?
- To run GUI applications.
- To automate system tasks and operations (Correct answer)
- To interact with hardware directly.
- To create user interfaces.
Correct answer: To automate system tasks and operations
Shell scripting in Linux involves writing sequences of commands into a script file for automated execution. Its primary purpose is to automate repetitive or complex system administration tasks and operations. This allows users to streamline workflows, perform batch processing, and improve efficiency by reducing manual intervention.
Which command is used to display the contents of a directory in Linux?