Linux Interview Questions and Answers

    Source: Sanfoundry

    Question set size: 44 items

    Linux MCQ (Multiple Choice Questions)

    Here are 1000 Linux MCQs (Chapterwise)

    .

    Interview Questions and Answers

    Question 1

    What is Linux primarily known as?

    • a) A web server
    • b) An operating system
    • c) A programming language
    • d) A hardware platform

    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.

    Question 2

    Who is the creator of the Linux kernel?

    • a) Linus Torvalds
    • b) Richard Stallman
    • c) Bill Gates
    • d) Steve Jobs

    Answer: a

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

    Question 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

    Answer: c

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

    Question 4

    Which of the following is a popular Linux distribution?

    • a) Windows
    • b) Ubuntu
    • c) MacOS
    • d) Android

    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.

    Question 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

    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.

    Question 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

    Answer: b

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

    Question 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

    Answer: a

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

    Question 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

    Answer: b

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

    Question 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

    Answer: b

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

    Question 10

    Which of the following commands is used to change the current directory?

    • a) cd
    • b) change
    • c) goto
    • d) setdir

    Answer: a

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

    Question 11

    Which command is used to list all files and directories in a Linux system?

    • a) ls
    • b) dir
    • c) list
    • d) show

    Answer: a

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

    Question 12

    Which command is used to change the ownership of a file in Linux?

    • a) chown
    • b) chmod
    • c) chgrp
    • d) mv

    Answer: a

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

    Question 13

    Which file contains the list of users in a Linux system?

    • a) /etc/users
    • b) /etc/passwd
    • c) /etc/groups
    • d) /etc/userlist

    Answer: b

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

    Question 14

    Which command is used to display the current working directory?

    • a) pwd
    • b) current
    • c) dir
    • d) ls

    Answer: a

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

    Question 15

    Which command is used to copy files in Linux?

    • a) copy
    • b) cp
    • c) mv
    • d) xcopy

    Answer: b

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

    Question 16

    Which of the following commands will display the contents of a file?

    • a) cat
    • b) view
    • c) show
    • d) display

    Answer: a

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

    Question 17

    Which command is used to search for a specific text string in a file?

    • a) grep
    • b) find
    • c) search
    • d) locate

    Answer: a

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

    Question 18

    Which command will change the current directory to the home directory?

    • a) cd ~
    • b) cd /home
    • c) cd .
    • d) cd ..

    Answer: a

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

    Question 19

    What does the ‘chmod’ command do?

    • a) Change file ownership
    • b) Change file permissions
    • c) Change file name
    • d) Change file location

    Answer: b

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

    Question 20

    Which command is used to create a new directory?

    • a) newdir
    • b) mkdir
    • c) createdir
    • d) dircreate

    Answer: b

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

    Question 21

    Which command can be used to display the last lines of a file?

    • a) tail
    • b) head
    • c) end
    • d) last

    Answer: a

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

    Question 22

    Which command is used to compress files in Linux?

    • a) zip
    • b) gzip
    • c) compress
    • d) tar

    Answer: b

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

    Question 23

    Which command displays the manual for another command?

    • a) help
    • b) man
    • c) guide
    • d) info

    Answer: b

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

    Question 24

    Which command is used to install a package in Debian-based distributions?

    • a) install
    • b) apt-get
    • c) yum
    • d) pkg

    Answer: b

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

    Question 25

    What does the ‘df’ command do?

    • a) Display free disk space
    • b) Display file permissions
    • c) Display system processes
    • d) Display current users

    Answer: a

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

    Question 26

    Which command is used to remove files in Linux?

    • a) delete
    • b) rm
    • c) rmdir
    • d) erase

    Answer: b

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

    Question 27

    Which command shows the current processes running in the system?

    • a) list
    • b) ps
    • c) top
    • d) run

    Answer: b

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

    Question 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

    Answer: b

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

    Question 29

    Which command can be used to monitor real-time system performance?

    • a) monitor
    • b) top
    • c) perf
    • d) stat

    Answer: b

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

    Question 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

    Answer: a

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

    Question 31

    Which of the following is a Linux distribution?

    • a) Ubuntu
    • b) Windows
    • c) MacOS
    • d) Solaris

    Answer: a

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

    Question 32

    What is the default shell for most Linux distributions?

    • a) tcsh
    • b) bash
    • c) sh
    • d) zsh

    Answer: b

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

    Question 33

    Which command is used to check network connectivity in Linux?

    • a) netstat
    • b) ping
    • c) trace
    • d) route

    Answer: b

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

    Question 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

    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.

    Question 35

    Which command is used to view the contents of a compressed file?

    • a) unzip
    • b) gunzip
    • c) extract
    • d) untar

    Answer: b

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

    Question 36

    Which file contains system-wide environment variables?

    • a) /etc/environment
    • b) /etc/profile
    • c) /etc/bashrc
    • d) All of the above

    Answer: d

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

    Question 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

    Answer: a

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

    Question 38

    Which command is used to display disk usage of files and directories?

    • a) du
    • b) df
    • c) space
    • d) usage

    Answer: a

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

    Question 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

    Answer: b

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

    Question 40

    Which command would you use to change to the root user?

    • a) su
    • b) root
    • c) admin
    • d) sudo

    Answer: a

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

    Question 41

    What command is used to manage user accounts in Linux?

    • a) useradd
    • b) adduser
    • c) usermod
    • d) All of the above

    Answer: d

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

    Question 42

    Which command is used to monitor system performance and resource usage?

    • a) vmstat
    • b) top
    • c) htop
    • d) All of the mentioned

    Answer: d

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

    Question 43

    Which command is used to schedule tasks in Linux?

    • a) at
    • b) cron
    • c) schedule
    • d) at and cron

    Answer: d

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

    Question 44

    Which directory contains log files for system events in Linux?

    • a) /var/log
    • b) /etc/log
    • c) /usr/log
    • d) /tmp/log

    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 Our 1000+ Linux MCQs focuses on both Linux Administration & Linux Systems Programming areas.

    Original page: https://www.sanfoundry.com/technical-interview-questions/