MCQs on Introduction to Shell | Shell Scripting

The shell is a powerful interface for interacting with the operating system. Learn about the types of shells, basic shell commands, and how to navigate the file system efficiently.


What is a Shell?

  1. What is the primary function of a shell?
    a) To manage hardware resources
    b) To provide a user interface for interacting with the operating system
    c) To compile programs
    d) To create network connections
  2. Which of the following is true about a shell in computing?
    a) It is a graphical user interface for the operating system
    b) It allows users to execute commands and manage system operations
    c) It is responsible for managing the network connections
    d) It is used for memory management
  3. Which of these is NOT typically a feature of a shell?
    a) Command execution
    b) File system navigation
    c) Memory management
    d) Job control
  4. Which of the following commands would launch a shell in Linux?
    a) start shell
    b) launch bash
    c) bash
    d) shell start
  5. What does a shell typically interpret and execute?
    a) Python code
    b) Shell commands and scripts
    c) Java programs
    d) HTML files

Types of Shells

  1. Which of the following is a common shell used in Linux?
    a) PowerShell
    b) Bash
    c) Command Prompt
    d) Zsh
  2. What is the main feature of the Zsh shell compared to Bash?
    a) It does not support scripting
    b) It provides better autocompletion and customization options
    c) It does not support command history
    d) It is not available in Linux
  3. Which shell is known for its compatibility with Unix-based systems?
    a) Zsh
    b) PowerShell
    c) Command Prompt
    d) Bash
  4. Which shell is most commonly used in macOS by default?
    a) Bash
    b) Zsh
    c) PowerShell
    d) Fish
  5. Which of these shells is commonly used for scripting on Linux systems?
    a) Zsh
    b) Bash
    c) PowerShell
    d) Cmd

Basic Shell Commands

  1. What does the pwd command do in a shell?
    a) Changes the current directory
    b) Prints the current working directory
    c) Lists files in the current directory
    d) Creates a new directory
  2. Which command is used to list files in a directory in the shell?
    a) list
    b) ls
    c) dir
    d) show
  3. What does the command mkdir do?
    a) Changes the current directory
    b) Displays files in a directory
    c) Creates a new directory
    d) Deletes a file
  4. Which of these commands is used to remove a file in a Unix-like system?
    a) del
    b) rm
    c) delete
    d) remove
  5. What is the purpose of the echo command in a shell?
    a) To list files in a directory
    b) To print text or variables to the screen
    c) To change directory
    d) To search for a pattern in files
  6. Which of the following commands is used to view the contents of a file?
    a) cat
    b) view
    c) see
    d) list
  7. How would you display the first 10 lines of a file using the shell?
    a) head
    b) tail
    c) show
    d) list
  8. What does the rm -r command do?
    a) Removes a file
    b) Removes a directory and its contents
    c) Renames a file
    d) Creates a directory
  9. Which command is used to copy files or directories?
    a) mv
    b) cp
    c) copy
    d) dup
  10. What does the man command do?
    a) Displays the manual page for a command
    b) Lists files in a directory
    c) Creates a new user
    d) Modifies system settings

Navigating the File System

  1. How would you move into a directory named Documents?
    a) cd Documents
    b) cd /Documents
    c) move Documents
    d) dir Documents
  2. What does the cd .. command do?
    a) Creates a new directory
    b) Changes to the parent directory
    c) Deletes the current directory
    d) Lists the contents of the current directory
  3. How can you return to your home directory in the shell?
    a) cd ~
    b) cd /home
    c) cd
    d) cd /
  4. Which of the following commands would take you to the root directory?
    a) cd /
    b) cd ~
    c) cd /home
    d) cd root
  5. In a Unix-like system, how would you display the contents of the /etc directory?
    a) ls /etc
    b) cd /etc
    c) dir /etc
    d) show /etc
  6. How would you find the path of the current directory?
    a) echo $PWD
    b) pwd
    c) echo $HOME
    d) get path
  7. What does the ls -l command do?
    a) Lists files with details such as permissions, size, and modified date
    b) Lists files in a simple format
    c) Lists files recursively
    d) Lists directories only
  8. How would you navigate to a subdirectory Projects inside the current directory?
    a) cd Projects
    b) cd ./Projects
    c) cd ../Projects
    d) cd ~/Projects
  9. Which command would you use to navigate to the parent directory of your current directory?
    a) cd /
    b) cd ..
    c) cd parent
    d) cd back
  10. What does the ls -a command do?
    a) Lists all files, including hidden ones
    b) Lists only directories
    c) Lists files alphabetically
    d) Lists files with permissions

Answer Key

QNoAnswer (Option with text)
1b) To provide a user interface for interacting with the operating system
2b) It allows users to execute commands and manage system operations
3c) Memory management
4c) bash
5b) Shell commands and scripts
6b) Bash
7b) It provides better autocompletion and customization options
8d) Bash
9b) Zsh
10b) Bash
11b) Prints the current working directory
12b) ls
13c) Creates a new directory
14b) rm
15b) To print text or variables to the screen
16a) cat
17a) head
18b) Removes a directory and its contents
19b) cp
20a) Displays the manual page for a command
21a) cd Documents
22b) Changes to the parent directory
23a) cd ~
24a) cd /
25a) ls /etc
26a) echo $PWD
27a) Lists files with details such as permissions, size, and modified date
28a) cd Projects
29b) cd ..
30a) Lists all files, including hidden ones

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top