Linux Quiz - MCQ - Multiple Choice Questions

Linux is an open-source operating system that has evolved into a cornerstone of the tech world. Whether you're stepping into the Linux environment for the first time or looking to solidify your foundational knowledge, this quiz will serve as an insightful learning resource. 

Dive in and test your understanding of the Linux operating system's fundamentals and commands with these 25 multiple-choice questions.

1. Which command is used to display the contents of a file?

A. show
B. display
C. print
D. cat

Answer:

D. cat

Explanation:

The 'cat' command is used to display the contents of a file.

2. Which of the following is the Linux command to change directories?

A. chdir
B. move
C. cd
D. dirchg

Answer:

C. cd

Explanation:

The 'cd' command is used to change directories.

3. What is the default shell in Linux?

A. bash
B. sh
C. ksh
D. csh

Answer:

A. bash

Explanation:

The 'bash' or Bourne Again SHell is the default shell for most Linux distributions.

4. Which command will display the current working directory?

A. pwd
B. cwd
C. dir
D. list

Answer:

A. pwd

Explanation:

The 'pwd' command displays the present working directory.

5. How do you list the hidden files in a directory?

A. ls
B. ls -a
C. dir /hidden
D. ls -h

Answer:

B. ls -a

Explanation:

The 'ls -a' command lists all files, including hidden ones.

6. Which symbol represents the root directory in Linux?

A. /
B. \
C. ~
D. !

Answer:

A. /

Explanation:

In Linux, the root directory is represented by a forward slash (/).

7. Which command is used to remove a directory?

A. rmdir
B. remove
C. del
D. delete

Answer:

A. rmdir

Explanation:

The 'rmdir' command is used to remove empty directories.

8. How do you print the first 10 lines of a file named 'file.txt'?

A. head -10 file.txt
B. first -10 file.txt
C. cat -10 file.txt
D. print -10 file.txt

Answer:

A. head -10 file.txt

Explanation:

The 'head' command with the '-10' option prints the first 10 lines of the specified file.

9. Which command displays a file's type?

A. showtype
B. displaytype
C. cattype
D. file

Answer:

D. file

Explanation:

The 'file' command is used to determine the type of a file.

10. What is the command to search for a pattern in a file?

A. search
B. find
C. grep
D. locate

Answer:

C. grep

Explanation:

The 'grep' command searches files for a specified pattern.

11. Which command is used to see the running processes in Linux?

A. process
B. run
C. top
D. exec

Answer:

C. top

Explanation:

The 'top' command displays a live, updating view of the running processes.

12. What does the command chmod 777 filename do?

A. Changes the owner of the file
B. Deletes the file
C. Gives read, write, and execute permissions to everyone for that file
D. Hides the file

Answer:

C. Gives read, write, and execute permissions to everyone for that file

Explanation:

The chmod 777 command gives all permissions (read, write, and execute) to the owner, the group, and everyone else.

13. Which command is used to find files in a directory?

A. locate
B. search
C. find
D. list

Answer:

C. find

Explanation:

The 'find' command is used to search and locate the list of files and directories based on conditions.

14. How do you display the last ten lines of a file in Linux?

A. bottom
B. last
C. tail
D. end

Answer:

C. tail

Explanation:

The 'tail' command by default shows the last ten lines of a file.

15. Which command is used to create a symbolic link?

A. symb
B. link
C. ln
D. connect

Answer:

C. ln

Explanation:

The 'ln' command is used to create links between files. The '-s' option creates a symbolic link.

16. How do you display your Linux system information?

A. info
B. uname -a
C. version
D. details

Answer:

B. uname -a

Explanation:

The uname -a command displays all the system information, including machine name, OS, kernel, etc.

17. Which command is used to stop a process in Linux?

A. stop
B. halt
C. kill
D. terminate

Answer:

C. kill

Explanation:

The 'kill' command is used to terminate a process manually.

18. What does the man command do?

A. Manages directories
B. Provides documentation or manual pages
C. Manages users
D. Monitors system performance

Answer:

B. Provides documentation or manual pages

Explanation:

The man command in Linux is used to display the user manual of any command that we can run on the terminal.

19. What command can replace characters in a file?

A. rep
B. change
C. sed
D. swap

Answer:

C. sed

Explanation:

The 'sed' command, also known as stream editor, can be used to perform basic text transformations on an input stream (a file or input from a pipeline).

20. Which command shows disk usage?

A. du
B. disk
C. space
D. usage

Answer:

A. du

Explanation:

The 'du' (Disk Usage) command is used to check the directory size in Linux.

21. What is the primary role of the sudo command?

A. To run processes in the background
B. To provide manual pages for commands
C. To execute a command as another user, typically the superuser
D. To search for files in a directory

Answer:

C. To execute a command as another user, typically the superuser

Explanation:

The sudo command allows a permitted user to execute a command as the superuser or another user, as specified in the sudoers file.

22. What is the purpose of the ls command?

A. To list the processes running on the system
B. To show the file size of a given file
C. To display the contents of a file
D. To list files in a directory

Answer:

D. To list files in a directory

Explanation:

The ls command is commonly used to list the files and directories in the current working directory.

23. How do you search for a specific word within a file?

A. lookup
B. grep
C. seek
D. findword

Answer:

B. grep

Explanation:

The grep command is used to search for specific text or patterns in a file.

24. If you want to repeat the last command in Linux, what would you type?

A. replay
B. !!
C. repeat
D. redo

Answer:

B. !!

Explanation:

Typing !! in the terminal and pressing enter will execute the last command.

25. How would you compress files using the Linux command line?

A. compress
B. minify
C. gzip
D. squeeze

Answer:

C. gzip

Explanation:

The gzip command is used to compress files. The files will then have a ".gz" extension.

26. Which command can you use to change the permissions of a file?

A. chown
B. chmod
C. chgroup
D. chperm

Answer:

B. chmod

Explanation:

The chmod command is used to change the permissions of a file or directory.


Comments