Linux MCQ (Multiple Choice Questions)

Here are 1000 Linux MCQs (Chapterwise).

1. What is Linux primarily known as?
a) A web server
b) An operating system
c) A programming language
d) A hardware platform
View Answer

Answer: b
Explanation: Linux is primarily known as an operating system, specifically a family of open-source Unix-like operating systems based on the Linux kernel.

2. Who is the creator of the Linux kernel?
a) Linus Torvalds
b) Richard Stallman
c) Bill Gates
d) Steve Jobs
View Answer

Answer: a
Explanation: Linus Torvalds is the creator of the Linux kernel, which he first released in 1991.

3. Which of the following statements is true about Linux?
a) It is a proprietary operating system
b) It is only used on servers
c) It is an open-source operating system
d) It does not support multitasking
View Answer

Answer: c
Explanation: Linux is an open-source operating system, meaning its source code is available for anyone to view, modify, and distribute.

4. Which of the following is a popular Linux distribution?
a) Windows
b) Ubuntu
c) MacOS
d) Android
View Answer

Answer: b
Explanation: Ubuntu is a popular distribution of Linux, known for its user-friendly interface and widespread use in both desktop and server environments.

5. What is the significance of the Linux kernel?
a) It provides a graphical user interface
b) It manages system resources and hardware communication
c) It stores user data
d) It compiles software programs
View Answer

Answer: b
Explanation: The Linux kernel is the core component of the operating system that manages system resources, hardware communication, and system calls from user applications.
advertisement

6. What command is used to display the version of the Linux kernel running on your system?
a) version
b) uname -r
c) kernel
d) sysinfo
View Answer

Answer: b
Explanation: The `uname -r` command displays the version of the Linux kernel currently running on the system.

7. Which command is used to update the package index in Debian-based systems?
a) apt-get update
b) yum update
c) pkg update
d) updatepkg
View Answer

Answer: a
Explanation: The `apt-get update` command is used to update the package index on Debian-based systems, such as Ubuntu.

8. In Linux, what is the purpose of the ‘root’ user?
a) A standard user with limited permissions
b) The system administrator with full privileges
c) A guest user
d) A service account
View Answer

Answer: b
Explanation: The ‘root’ user is the system administrator in Linux, having full access and control over the system.

9. What does the ‘ls -a’ command do?
a) Lists all files except hidden ones
b) Lists all files including hidden ones
c) Lists only directories
d) Lists files in a detailed format
View Answer

Answer: b
Explanation: The `ls -a` command lists all files and directories in the current directory, including hidden ones (those starting with a dot).

10. Which of the following commands is used to change the current directory?
a) cd
b) change
c) goto
d) setdir
View Answer

Answer: a
Explanation: The `cd` (change directory) command is used to change the current working directory in Linux.

11. Which command is used to list all files and directories in a Linux system?
a) ls
b) dir
c) list
d) show
View Answer

Answer: a
Explanation: The `ls` command is used to list files and directories in the current directory in Linux.

12. Which command is used to change the ownership of a file in Linux?
a) chown
b) chmod
c) chgrp
d) mv
View Answer

Answer: a
Explanation: The `chown` command is used to change the ownership of files and directories in Linux.

13. Which file contains the list of users in a Linux system?
a) /etc/users
b) /etc/passwd
c) /etc/groups
d) /etc/userlist
View Answer

Answer: b
Explanation: The `/etc/passwd` file contains user account information, including usernames and user IDs.

14. Which command is used to display the current working directory?
a) pwd
b) current
c) dir
d) ls
View Answer

Answer: a
Explanation: The `pwd` (print working directory) command displays the full path of the current directory.

15. Which command is used to copy files in Linux?
a) copy
b) cp
c) mv
d) xcopy
View Answer

Answer: b
Explanation: The `cp` command is used to copy files and directories in Linux.

16. Which of the following commands will display the contents of a file?
a) cat
b) view
c) show
d) display
View Answer

Answer: a
Explanation: The `cat` command is used to display the contents of a file in the terminal.

17. Which command is used to search for a specific text string in a file?
a) grep
b) find
c) search
d) locate
View Answer

Answer: a
Explanation: The `grep` command is used to search for specific text patterns within files.

18. Which command will change the current directory to the home directory?
a) cd ~
b) cd /home
c) cd .
d) cd ..
View Answer

Answer: a
Explanation: The command `cd ~` changes the current directory to the user’s home directory.

19. What does the ‘chmod’ command do?
a) Change file ownership
b) Change file permissions
c) Change file name
d) Change file location
View Answer

Answer: b
Explanation: The `chmod` command is used to change the permissions of a file or directory in Linux.
advertisement

20. Which command is used to create a new directory?
a) newdir
b) mkdir
c) createdir
d) dircreate
View Answer

Answer: b
Explanation: The `mkdir` command is used to create new directories in the file system.

21. Which command can be used to display the last lines of a file?
a) tail
b) head
c) end
d) last
View Answer

Answer: a
Explanation: The `tail` command displays the last few lines of a file in the terminal.

22. Which command is used to compress files in Linux?
a) zip
b) gzip
c) compress
d) tar
View Answer

Answer: b
Explanation: The `gzip` command is used to compress files in Linux, producing a .gz file.

23. Which command displays the manual for another command?
a) help
b) man
c) guide
d) info
View Answer

Answer: b
Explanation: The `man` command is used to display the manual pages for other commands in Linux.

24. Which command is used to install a package in Debian-based distributions?
a) install
b) apt-get
c) yum
d) pkg
View Answer

Answer: b
Explanation: The `apt-get` command is used to install and manage packages in Debian-based Linux distributions.

25. What does the ‘df’ command do?
a) Display free disk space
b) Display file permissions
c) Display system processes
d) Display current users
View Answer

Answer: a
Explanation: The `df` command displays information about disk space usage on mounted filesystems.

26. Which command is used to remove files in Linux?
a) delete
b) rm
c) rmdir
d) erase
View Answer

Answer: b
Explanation: The `rm` command is used to remove files and directories in Linux.

27. Which command shows the current processes running in the system?
a) list
b) ps
c) top
d) run
View Answer

Answer: b
Explanation: The `ps` command displays information about currently running processes on the system.

28. Which file is responsible for the boot loader configuration in Linux?
a) /etc/boot.conf
b) /boot/grub/grub.cfg
c) /boot/loader.conf
d) /etc/grub.cfg
View Answer

Answer: b
Explanation: The `/boot/grub/grub.cfg` file is the configuration file for the GRUB boot loader.

29. Which command can be used to monitor real-time system performance?
a) monitor
b) top
c) perf
d) stat
View Answer

Answer: b
Explanation: The `top` command provides a dynamic view of system processes and their resource usage in real time.

30. Which command can be used to view the contents of a directory in a detailed format?
a) ls -l
b) dir -l
c) list -a
d) ls -a
View Answer

Answer: a
Explanation: The `ls -l` command displays files and directories in a detailed (long) format, including permissions, owner, size, and modification date.

31. Which of the following is a Linux distribution?
a) Ubuntu
b) Windows
c) MacOS
d) Solaris
View Answer

Answer: a
Explanation: Ubuntu is a popular distribution (distro) of Linux, while Windows and MacOS are not Linux-based operating systems.

32. What is the default shell for most Linux distributions?
a) tcsh
b) bash
c) sh
d) zsh
View Answer

Answer: b
Explanation: The default shell for most Linux distributions is `bash` (Bourne Again SHell).

33. Which command is used to check network connectivity in Linux?
a) netstat
b) ping
c) trace
d) route
View Answer

Answer: b
Explanation: The `ping` command is used to check network connectivity to a specified host by sending ICMP Echo Request packets.

34. What is the purpose of the ‘sudo’ command?
a) To switch users
b) To execute a command as a superuser
c) To shut down the system
d) To display disk usage
View Answer

Answer: b
Explanation: The `sudo` command allows a permitted user to execute a command as the superuser or another user, as specified by the security policy.

35. Which command is used to view the contents of a compressed file?
a) unzip
b) gunzip
c) extract
d) untar
View Answer

Answer: b
Explanation: The `gunzip` command is used to decompress files that have been compressed using `gzip`.

36. Which file contains system-wide environment variables?
a) /etc/environment
b) /etc/profile
c) /etc/bashrc
d) All of the above
View Answer

Answer: d
Explanation: All of these files can contain system-wide environment variables in Linux, depending on the specific settings and user sessions.

37. What is the purpose of the ‘kill’ command?
a) To terminate processes
b) To restart services
c) To delete files
d) To change user permissions
View Answer

Answer: a
Explanation: The `kill` command is used to send signals to processes, typically to terminate them gracefully or forcefully.

38. Which command is used to display disk usage of files and directories?
a) du
b) df
c) space
d) usage
View Answer

Answer: a
Explanation: The `du` (disk usage) command is used to estimate and report the disk space used by files and directories.

39. In Linux, what is the purpose of the ‘etc’ directory?
a) Contains user home directories
b) Contains system configuration files
c) Contains executable programs
d) Contains temporary files
View Answer

Answer: b
Explanation: The `/etc` directory contains system configuration files for various applications and services in Linux.

40. Which command would you use to change to the root user?
a) su
b) root
c) admin
d) sudo
View Answer

Answer: a
Explanation: The `su` command is used to switch to another user account, including the root user, if the correct password is provided.

41. What command is used to manage user accounts in Linux?
a) useradd
b) adduser
c) usermod
d) All of the above
View Answer

Answer: d
Explanation: All these commands (`useradd`, `adduser`, and `usermod`) are used to manage user accounts in Linux, each serving different functions.

42. Which command is used to monitor system performance and resource usage?
a) vmstat
b) top
c) htop
d) All of the mentioned
View Answer

Answer: d
Explanation: `vmstat`, `top`, and `htop` are all commands used to monitor system performance and resource usage in Linux.

43. Which command is used to schedule tasks in Linux?
a) at
b) cron
c) schedule
d) at and cron
View Answer

Answer: d
Explanation: Both the `at` command (for one-time scheduled tasks) and `cron` (for recurring tasks) are used to schedule tasks in Linux.

44. Which directory contains log files for system events in Linux?
a) /var/log
b) /etc/log
c) /usr/log
d) /tmp/log
View Answer

Answer: a
Explanation: The `/var/log` directory contains log files for various system events, applications, and services in Linux.


Chapterwise Multiple Choice Questions on Linux

Linux MCQ - Multiple Choice Questions and Answers

Our 1000+ Linux MCQs focuses on both Linux Administration & Linux Systems Programming areas. These MCQs are useful for both experienced professionals as well as freshers. These Linux MCQ have been broken down into various sections of Linux kernel viz. process management, memory management, file management, interprocess communication, signal handling, and so on.
  1. Linux Administration Interview Questions
  2. Linux Developer, Makefile, Debugging & Build Environment MCQs
  3. Linux Programming Interview Questions
  4. Linux Program Debugging/Tricky/Buggy Questions with Code/Examples

Linux Administration Interview Questions

Linux administration is essential for managing systems effectively. This section features multiple-choice questions (MCQs) that highlight the key skills every Linux administrator should have.

Linux Administration Interview Questions
Linux Environment – 1
Linux Environment – 2
Linux Environment – 3
Linux Commands – 1
Linux Commands – 2
Linux Commands – 3
Linux Commands – 4
Linux File Management – 1
Linux File Management – 2
Linux File Types
Linux File Permissions – 1
Linux File Permissions – 2
Linux File System Overview
Linux Startup and Shutdown
Linux Process Management
Linux User Account Management
Linux Shell Programming
Linux Shell Environment – 1
Linux Shell Environment – 2
Linux Shell Redirection
Linux Shell Special Symbols
Linux Search Pattern
Linux Shell Functions
Linux Shell Variables
Linux Bash Arithmetic Expressions
Linux Bash Command History & Job Control
Linux Bash Built-in Commands – 1
Linux Bash Built-in Commands – 2
Linux Bash Built-in Commands – 3
Linux vi Editor
Linux sed Editor
Awk Programming Basics
Awk Programming Expressions
Awk Programming Control Statements
Awk Programming Functions
Awk Programming Varaibles and Arrays
Linux Filesystem Hierarchy – 1
Linux Filesystem Hierarchy – 2
Linux Proc Filesystem – 1
Linux Proc Filesystem – 2
Linux Proc Filesystem – 3
Linux Proc Filesystem – 4
Linux Proc Filesystem – 5

Linux Developer, Makefile, Debugging & Build Environment MCQs

For developers working in a Linux environment, understanding Makefiles, debugging, and build processes is essential. This section covers a range of multiple-choice questions related to Linux development practices.

Linux Developer, Makefile, Debugging & Build Environment MCQs
Makefile Questions & Answers – 1
Makefile Questions & Answers – 2
GCC Compiler Various Options – 1
GCC Compiler Various Options – 2
GCC Compiler Various Options – 3
GCC Compiler – Stages of Compilation – 1
GCC Compiler – Stages of Compilation – 2
Static Libraries Questions & Answers
Shared Libraries Questions & Answers
GDB Debugger Questions & Answers – 1
GDB Debugger Questions & Answers – 2
GDB Debugger Questions & Answers – 3
GDB Debugger Questions & Answers – 4
GDB Debugger Questions & Answers – 5
Linux Sysfs Questions & Answers – 1
Linux Sysfs Questions & Answers – 2
Linux Sysfs Questions & Answers – 3
Linux Sysfs Qusetions & Answers – 4
Linux Sysfs Questions & Answers – 5
Device Drivers Major-Minor Numbers Questions

Linux Programming Interview Questions

Linux programming covers a range of important topics needed to build efficient applications. This section features key questions that focus on fundamental programming concepts in a Linux environment.

Linux Programming Interview Questions
Linux Process Management
Linux Memory Management
Linux File Management – 1
Linux File Management – 2
Linux Signal Handling
Linux IPCs – 1
Linux IPCs – 2
Linux Systems

Linux Program Debugging/Tricky/Buggy Questions with Code/Examples

Debugging is an important skill for every programmer. This section includes questions that test your knowledge of common mistakes and tricky code examples.

Linux Program Debugging/Tricky/Buggy Questions with Code/Examples
Memory Allocator Debugging Questions – malloc, calloc, free and realloc Calls – 1
Memory Allocator Debugging Questions – malloc, calloc, free and realloc Calls – 2
File Handling Debugging Questions – dup, fcntl, lseek and read System Calls
Process Management Debugging Questions – fork, exec and wait System Calls
Debugging Questions – Signal Handling System Calls
System Resource Debugging Questions – Timer, User & Resource Limit System Calls
Debugging Questions – Posix Threads
Debugging Questions – PThreads Handling
Debugging Questions – Named and Un-named Pipe Calls
Debugging Questions – System-V IPCs – Message Queues, Shared Memory and Semaphores
Debugging Questions – POSIX IPCs – Message Queues, Shared Memory and Semaphores
Debugging Questions – Unix Domain Sockets
Debugging Questions – Internet Domain Socket System Calls
If you would like to learn "Linux" thoroughly, you should attempt to work on the complete set of 1000+ MCQs - multiple choice questions and answers mentioned above. It will immensely help anyone trying to crack an exam or an interview.

Wish you the best in your endeavor to learn and master Linux!

Important Links:

advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
I’m Manish - Founder and CTO at Sanfoundry. I’ve been working in tech for over 25 years, with deep focus on Linux kernel, SAN technologies, Advanced C, Full Stack and Scalable website designs.

You can connect with me on LinkedIn, watch my Youtube Masterclasses, or join my Telegram tech discussions.

If you’re in your 40s–60s and exploring new directions in your career, I also offer mentoring. Learn more here.