Linux Multiple Choice Questions - Part 1
In this article, we test our Linux knowledge by going over 60 multiple choice questions.
1. Which among the following is used to schedule jobs in Linux?
(a) time
(b) schedule
(c) cron
(d) cal
Ans: (c)
Explanation: Cron is a Linux job scheduler. It uses the crontab daemon to store a list of jobs in a table. For more information on cron command, we can execute the command crontab --help. The time command is used to estimate how long a command/process takes to execute. For example, we can estimate how long it takes a program to execute by prepending 'time' before the execution command. The cal command displays a calender in most UNIX-based systems.
2. Which is NOT a file management command?
(a) ls
(b) pwd
(c) mkdir
(d) ping
Ans: (d)
Explanation: The ping command is a Linux networking command used to send ICMP packets to a remote host. The ls command is used to list the contents of a directory. mkdir command creates a new directory in the current working directory. pwd prints the current working directory. The cd command is used to change directories, we can also use chdir command.
3. Which is NOT a Linux networking command?
(a) netstat
(b) ifconfig
(c) touch
(d) nslookup
Ans: (c)
Explanation: The touch command is used to create new files in a directory. The netstat command is used to show the network statistics. ifconfig is commonly used to get the ip address and other network information such as the subnet of a Linux system. nslookup queries the internet domain name servers to obtain DNS records of a domain.
4. Linux is?
(a) Open source.
(b) Licensed software.
(c) Paid software.
(d) Free software.
Ans: (a, d)
Explanation: Linux is open source free software that can be downloaded, installed, or modified. Not all free software is open source and not all open source software is free. Some open-source software is licensed and not free to use or reproduce.
5. Who is the creator of Linux?
(a) Linux Foundation
(b) Linux Torvalds
(c) Linus Torvalds
(d) Linux developers
Ans: (c)
Explanation: Linus Torvalds created the Linux kernel in 1991. It was relicensed under GNU GLP and distributions started being created.
6. Which among the command is used to remove a directory with files?
(a) rmdir
(b) rm
(c) rm -r
(d) rmdir -r
Ans: (c)
Explanation: The rm command accompanied with the r option for 'recursive' is used to remove a directory with files. rmdir command can only remove empty directories. The -r(recursive) option recursively removes subdirectories and files. rm command can be used to remove a file.
7. What does GNU stand for?
(a) None of the below
(b) General Network, Unix
(c) General Network, Unity
(d) GNU's not Unix
Ans: (d)
Explanation: GNU stands for GNU's not Unix. GNU is a collection of free software that has extensive applications. It can be used as an operating system or parts of it taken and integrated with other operating systems. GNU software is licensed under GPL(General Public License) license.
8. Which command can be used to list all files in a directory?
(a) ls
(b) touch
(c) ls -d
(d) ls --dir
Ans: (a)
Explanation: The ls command is used to list all files in a directory. The touch command creates a new file in the current directory. ls -d
9. Which command can be used to list all hidden files?
(a) ls -s
(b) ls .
(c) ls -a
(d) ls -d.
Ans: (c)
Explanation: To view all files including hidden files, we use the ls -a command. '-s' option prepends the file size to the file name. ls '-d' only lists directories and not their contents.
10. Which command/keys are used to print a history of previous commands?
(a) up and down arrow keys
(b) history
(c) !
(d) None of the above
Ans: (b)
Explanation: The history command prints all previously executed commands. The previously executed commands are located in the ~/.bash_history file. After printing all previously executed commands we can prepend '!' before the command history number to re-execute the command. up and down arrow keys are useful for cycling through commands in a terminal.
11. Which command is used to list directories including their contents(recursively)?
(a) ls -R
(b) ls -a
(c) ls -r
(d) ls --dir
Ans: (a)
Explanation: The ls -R command not only lists files in a directory but recursively lists files inside directories within the root directory. ls -a lists everything including hidden files. At times the files and directories are too much to fit on a screen the -r option reverses the listing to display the last first, we can also combine(pipe) to the grep and pass a pattern.
12. Which command is used to count the number of words in a text?
(a) ws -c
(b) wc -w
(c) wc -l
(d) wc -m
Ans: (b)
Explanation: The -w option is used with the wc - word count command to get the number of words in a document. -c prints the byte count, -m the character count, -l the number of lines in a file.
13. Which command is used to count the number of lines in a document?
(a) wc -c
(b) wc -w
(c) wc -l
(d) wc -m
Ans: (c)
Explanation: We use the -l option to count the number of lines in a document. -c prints the byte count, -m the character count, -w to get the number of words used in a file.
14. Which is NOT a Linux text editor?
(a) Vim
(b) Nano
(c) Vi
(d) None of the above
Ans: (d)
Explanation: Other text editors include, Emacs, sublime text, and brackets among others.
15. Which is NOT a Linux distribution?
(a) Debian
(b) Ubuntu
(c) Fedora
(d) None of the above.
Ans: (d)
Explanation: Other Linux distributions include, Mandriva, alpine, and peppermint OS among others.
16. Which is a protocol used for remote connections in Linux?
(a) HTTPS
(b) HTTP
(c) SSH
(d) ICMP
Ans: (c)
Explanation: SSH is used to provide an encrypted connection to a remote host. In Linux, the ssh command is used for SSH connections to remote hosts. HTTP governs how data is transmitted over the web its secure version is HTTPS. ICMP is used by the ping command to send ICMP packets. It is mostly used to test connectivity to remote hosts.
17. In VIM/VI which command is used to delete a single character?
(a) yy
(b) x
(c) dd
(d) k
Ans: (b)
Explanation: To delete a single character in VIM/VI we use the x key. 'k' is used to move up a file, j down a file, l to the right, and h to the left. If we press 'dd' we delete a whole line. if we press 'yy' we copy a line, we can paste it at another location by pressing 'p'. A very helpful VIM cheatsheet.
18. What command can we use to create a new file system?
(a) mkfs
(b) fsck
(c) mkfile
(d) mkdir
Ans: (a)
Explanation: The mkfs command is used to create a new file system in Linux. The fsck command is used to check the Linux file system for errors. mkfile command is used to create files in Linux, for example;
$ mkfile 10m ~/newfile.txt
The above command creates a 10MB file that is padded with zeros.
19. Which among the following is NOT a Linux file system?
(a) Ext4
(b) Ext5
(c) Btrfs
(d) ReiserFS
Ans: (b)
Explanation: Ext5 is not a Linux file system. Other Linux file systems include XFS, JFS, Ext, Ext2, and Ext3 among others, Linux supports over 100 different types of file systems.
20. Which command is NOT a communication command in Linux?
(a) ping
(b) write
(c) mesg
(d) None of the above
Ans: (a)
Explanation: Ping is NOT a communication command rather it is a networking command. The write command allows users to send messages to our terminal session. We can toggle it on or off(allow or disallow)[- y / -n]. The write command is used to send messages to another user in Linux.
21. Which is NOT a system information gathering command?
(a) uname
(b) uptime
(c) date
(d) None of the above
Ans: (d)
Explanation: Other system information gathering commands include, hostname, last reboot, dmidecode, w, lshw, lscpu, lsblk, lsusb, lspci, lsscsi, hdparm, fdisk,
22. Which of the commands is NOT a command that can be used to gather hardware information?
(a) lspci -tv
(b) cat /proc/cpuinfo
(c) None of the above
(d) hdparm -i /dev/sda
Ans: (c)
Explanation: Other hardware information gathering commands include, badblocks -s /dev/sda to test for unreadable blocks on a disk, lsusb -tv to print connected USB devices, free -h to print memory information among others mentioned in question (21).
23. Which command is used to print information regarding system performance and statistics?
(a) top
(b) htop
(c) lsof
(d) whoami
Ans: (d)
Explanation: Other related commands include, vmstat, and iostat, among others. htop and top are similar although the former is superior. The lsof(list open files) command is used to get the user processes actively using a file system. The whoami command returns the currently logged-in user.
24. Which command is NOT a user management command?
(a) htop
(b) useradd
(c) id
(d) userdel
Ans: (a)
Explanation: Other user management commands include, groupadd, who, w, usermod, adduser, addgroup, delgroup, chage, sudo, su among others. htop is not a user management command but rather a process management command.
25. Which among the commands is a file management command?
(a) ls
(b) ln
(c) tail
(d) All the above
Ans: (d)
Explanation: Other file management commands include, touch, cat, head, less, rm, rmdir, find, locate, cp, mv, cd, mkdir, and pwd among others.
26. Which command is a process management command in Linux?
(a) ps
(b) All the above
(c) kill
(d) bg
Ans: (b)
Explanation: Other process management commands are kill, killall, fg, top, and htop. The kill command is used to terminate a process manually. fg and bg commands are used to run background and foreground jobs.
27. Select Linux networking commands?
(a) dig
(b) ip
(c) All the above
(d) whois
Ans: (c)
Explanation: Other Linux networking commands include wget, curl, netstat host, hostname, ipconfig, and ping among others. The dig command 'digs' for DNS information. The whois command is used to perform lookups from the command line, for example, we can write;
$ whois google.com
The ip command is a very useful command for showing, manipulating, routing, devices, policy routing, and tunnels among other networking functions.
28. Which among the commands can be used for archiving in Linux?
(a) tar cf archive.tar directory
(b) tar xf archive.tar
(c) tar czf archive.tar.gz directory
(d) All the above
Ans: (d)
Explanation: The tar command saves many files together into a single tape or disk archive, and can also be used to restore individual files from the archive.
29. Which command is used for package management in Linux?
(a) All the below
(b) rpm
(c) dnf
(d) yum
Ans: (a)
Explanation: Package management in Linux involves searching, installing, configuring, updating, and removing software packages. Other Linux package managers include apt, aptitude, pacman, portage.
30. Which command canNOT be used for search purposes in Linux.?
(a) locate
(b) None of the above
(c) find
(d) grep
Ans: (b)
Explanation: locate, find and grep commands in Linux are used to search for files, directories, text, characters in Linux. The locate command finds files in a file system. The find command is more aggressive compared to the former since it uses recursion to search a file system. The 'which' command is used to search through directories defined in the $PATH environment variable. The grep command matches patterns in a file.
31. Which command is used for remote file transfer in Linux?
(a) scp
(b) rsync
(c) None of the Above
(d) All the above
Ans: (d)
Explanation: scp and rsync are commands that are used to securely copy files remotely. The former is based on SSH. It is commonly used to transfer files from a localhost to a remote host securely. SSH is used for encryption purposes. The rsync command synchronizes files/directories either on localhost or on the remote host, it is commonly used to update backup files and directories.
32. What Linux commands are used to check the disk usage?
(a) df -h
(b) df -i
(c) None of the above
(d) du -sh
Ans: (c)
Explanation: Other commands to check for Linux disk space are fdisk -l which prints all disk partitions, du -ah to print the disk usage in a human-readable format.
33. Which command is used to change the current directory?
(a) cd
(b) cp
(c) chdir
(d) mv
Ans: (a)
Explanation: The cd(change directory) command is used to navigate the Linux file system. The cp command is used to copy files in Linux. chdir is also a valid answer in this question. mv command is used to rename or move a file or directory.
34. What makes up the Linux core?
(a) Kernel
(b) Terminal
(c) Users
(d) Commands
Ans: (a)
Explanation: The kernel is the core of the Linux operating system. It is free open source code used in the monolithic, multitasking, multiuser UNIX operating system. It was created by Linus Torvalds in 1991. We can find the code here.
35. What is the maximum size of a file name in Linux?
(a) 1024 bytes
(b) 2048 bytes
(c) 255 bytes
(d) None of the above
Ans: (c)
Explanation: A file name in Linux should be less than 255 bytes in length. This can be changed using the ulimit command accompanied by the -f option and the desired maximum file size.
36. Which distribution is NOT based on the core Linux?
(a) BSD
(b) Ubuntu
(c) CentOS
(d) Alpine
Ans: (a)
Explanation: BSD is NOT based on Linux. Other Linux distributions include Gentoo, RHEL, Kali Linux, Arch Linux, CentOS, Mint among others.
37. In Linux, where are passwords stored?
(a) /etc/passwd
(b) /etc/password
(c) /etc/sys/passwd
(d) /etc/bin/passw
Ans: (a)
Explanation: User passwords in Linux are stored in the /etc/passwd file. The passwd command is used to change a user password on a Linux system.
38. Is a directory a file in Linux?
(a) True
(b) False
(c) None of the above
Ans: (a)
Explanation: In Linux everything is a file, including directories, commands, services, users, etc. This is a defining feature for UNIX systems. from usb sticks, network devices, applications, keyboards, and storage devices, everything is a file in Linux. A more accurate description would be to say that everything in Linux is a file descriptor since when a file is opened a file descriptor is created which becomes the byte stream I/O interface.
39. Which symbol is used to represent the top-level directory?
(a) ~
(b) @
(c) `
(d) /
Ans: (d)
Explanation: The root directory(/) is the top-level directory in a Linux file system. We can do a lot of damage to a system by;
$ rm -rf /
Here we remove the entire root directory, if the root of the tree is destroyed, so are the subdirectories and their files. This can be tested in a virtual environment.
40. Which among the following commands is used to print the current working directory?
(a) cd
(b) ls
(c) pwd
(d) whoami
Ans: (c)
Explanation: The pwd(print working directory) command prints out the current working directory. We can also get the current working directory from an environment variable, can you guess which? The whoami command prints the currently logged-in user.
41. Which option is used to list files while classifying them?
(a) -l
(b) -F
(c) -a
(d) -c
Ans: (b)
Explanation: The ls -F command not only lists files but classifies them. For example, directories are prepended with a '/' character to signify that they are directories.
42. Which command is used to create a new directory?
(a) touch
(b) rmdir
(c) mkdir
(d) None of the above
Ans: (c)
Explanation: The mkdir command is used to create a new directory. The touch command creates a new file. rmdir removes an empty directory. If the directory has contents then we use rm -r command.
43. Which command is canNOT be used to shut down a Linux system?
(a) shutdown now
(b) shutdown
(c) reboot
(d) None of the above
Ans: (d)
Explanation: We can reboot or shut down a Linux machine immediately or schedule the shutdown with a message all from the command line. If scheduled, a message is displayed to all logged-in users.
44. Which command is used to copy files are directories recursively?
(a) cp -r
(b) cp -s
(c) cp -a
(d) None of the above
Ans: (a)
Explanation: The r(recursive) option is used to recursively copy directories, their sub-directories, and files.
45. Which command is used to rename a file in Linux?
(a) rename
(b) cp
(c) mv
(d) None of the above
Ans: ((c)
Explanation: To rename a file in Linux, we need to move it into a new file or directory with a different name. No file or directory contents are changed.
46. Which symbol is NOT used for redirection in the Linux terminal?
(a) >
(b) >>
(c) <
(d) None of the above
Ans: (d)
Explanation: > and >> are used to redirect output to a file or another command. The former appends the redirected input to a file and erases what was previously there. The latter appends to it without removing previous contents. '<' is used to redirect input.
47. What is the default file system in Linux?
(a) ext3
(b) ext4
(c) btrfs
(d) swap
Ans: (b)
Explanation: ext4 is the default file system for Linux. It is an improved version of ext3 file system. Unlike the former it is more stable and cutting edge.
48. Which command is used to print files in Linux?
(a) la
(b) lp
(c) pr
(d) None of the above
Ans: (b)
Explanation: The lp command is used to print files in Linux. The pr command prepares files for printing purposes. la command lists files and directories.
49. Select the path for the Apache server config file located.
(a) /etc/bin/httpd.conf
(b) /etc/httpd/conf/httpd.conf
(c) /
(d) None of the above
Ans: (b)
Explanation: The Apache config file is located in the /etc/httpd/conf/ directory. '/' represents the root directory of the Linux file system.
50. What does OSS refer to?
(a) Open source systems
(b) Open source software
(c) Open source servers
(d) None of the above
Ans: (b)
Explanation: OSS stands for open source software. Note that not all open source software is free for use.
51. Which command among the following is used to append to a file in Linux?
(a) cat >>
(b) cat >
(c) cat <<
(d) cat <
Ans: (a)
Explanation: To append to a file we write cat >> file.txt. After execution, any text we write will be appended to file.txt. By using '>' we erase the contents of the file we are appending to add the new data. '<' is used to read files in Linux.
52. What is the maximum number of primary partitions one can have in a single drive?
(a) 1
(b) 2
(c) 3
(d) 4
Ans: (d)
Explanation: We can have a maximum of four partitions in Linux. In Linux, disks are divided into three types or partitions, primary, extended, and logical. We can create up to 4 primary partitions.
53. What directory allows sysadmins to create a default home directory for all new users on a computer or network?
(a) /etc/hosts/
(b) /etc/usr/
(c) /etc/skel/
(d) None of the above
Ans: (c)
Explanation: User default files are stored in the /etc/skel/ directory in Linux. When the operating system is installed user configuration files are placed in /etc/skel by default.
54. In vim which key is used to replace text?
(a) R
(b) r
(c) x
(d) o
Ans: (a)
Explanation: We can replace text instead or erase it by using the R option. x is used to erase text without replacing it. o is used to jump to the next line. r replaces a single character.
55. Where are Linux configuration files stored?
(a) /opt
(b) /bin
(c) /etc
(d) /sbin
Ans: (c)
Explanation: Linux system configuration files are stored in the /etc/ directory. The /opt directory stores configuration files for add-on packages. /bin stores important command binaries that need to be available in single-user mode. /sbin directory stores important system binaries such as fsck, init among others.
56. Where are system binaries stored in Linux?
(a) /bin
(b) /sbin
(c) /lib
(d) /mnt
Ans: (b)
Explanation: System binaries are stored in the /sbin directory. These require root privileges for execution. The /lib directory stores important libraries for the binaries in the/bin and /sbin directories. The /mnt directory stores temporarily mounted files and directories.
57. Which option is used to recursively perform an action in Linux?
(a) -r
(b) --rec
(c) -rf
(d) -ri
Ans: -r
Explanation: We use the -r with other commands such as cp, rm to recursively perform an action for example copying or deleting directories, their subdirectories, and files.
58. Where are optional software packages stored in Linux?
(a) /opt
(b) /boot
(c) /sbin
(d) /etc
Ans: (a)
Explanation: Optional software packages are stored in the /opt directory in Linux. The /etc directory stores host-specific system-wide configuration files. /boot stores boot loader files such as kernels, initrd.
59. Where are system libraries stored in Linux?
(a) /tmp
(b) /sys
(c) /lib
(d) /proc
Ans: (c)
Explanation: In Linux libraries are stored in the /lib directory. The /proc directory is a virtual filesystem that stores process and kernel information as files. The /sys directory stores information about devices, drivers, and some kernel features. The /tmp directory stores temporary files.
60. Which option is used to ignore case sensitivity in Linux?
(a) -ig
(b) -i
(c) -m
(d) -f
Ans: (b) Explanation: The -i option is used with many commands to ignore case sensitivity. For example, we can search the contents of a file using grep -i to ignore case sensitivity, this way to return both uppercase and lowercase matches.
Subscribe to my newsletter
Read articles from lumunge directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by