Linux Commands Multiple Choice - Quiz, Trivia & Questions
Linux Commands Multiple Choice - Quiz, Trivia & Questions
Start
Create your own Quiz
Hey, check out this incredible 'Linux commands multiple-choice quiz' that consists of
well-researched questions and answers. This quiz is perfect for anyone who is in
college studying Linux, systems administration, or other computer courses and want
to test themselves on multiple-choice questions for exams. So, are you ready to take
this test? Do you think you can pass it? Let's start the quiz and see how well you
score. Good luck!
B. Run init
D. Load modules
Correct Answer
A. Load initial ramdisk
Explanation
After the phase called "load kernel" during the Linux boot process, the
next step is to load the initial ramdisk. The initial ramdisk, also known as
initrd or initramfs, is a temporary le system that contains essential les
and drivers needed to boot the system. It is loaded into memory and
used as a temporary root le system until the actual root le system can
be mounted. The initial ramdisk provides necessary modules and scripts
for the system to initialize and prepare for the next phase of the boot
process.
A. Cp -r Project Project.backup
B. Cp -e Project Project.backup
C. Cp -d Project Project.backup
D. Cp -s Project Project.backup
Correct Answer
A. Cp -r Project Project.backup
Explanation
The correct answer is "cp -r Project Project.backup". The "-r" option in the
"cp" command stands for "recursive" which allows the entire directory
structure to be copied. By specifying the source directory "Project" and
the destination directory "Project.backup", the command will recursively
copy all the les and subdirectories from "Project" to "Project.backup".
A. Crontab -c
B. Crontab -e
C. Crontab -make
D. Crontab --create
Correct Answer
B. Crontab -e
Explanation
To create a crontab entry, the correct command is "crontab -e". This
command allows the user to edit the crontab le, which contains the
schedule of cron jobs to be executed. By using this command, the user
can add, modify, or remove cron jobs according to their requirements.
A. Crontab -d
B. Crontab -e
C. Crontab -r
D. Del -crontab
Correct Answer
C. Crontab -r
Explanation
To delete a crontab entry, you can use the command "crontab -r". This
command removes all the cron jobs associated with the user's crontab
le. It effectively deletes the entire crontab entry for the user, removing
any scheduled tasks or commands that were previously set up.
Correct Answer
A. Put an & symbol at the end of the command line.
Explanation
To direct the shell to execute a command in the background, you need to
put an & symbol at the end of the command line. This allows the
command to run in the background while you can continue using the
shell for other tasks.
A. Kernel -r
B. Uname -r
C. Cat /proc/etc/kernel/release
Correct Answer
B. Uname -r
Explanation
The correct answer is "uname -r". The "uname" command is used to
display various system information, and the "-r" option speci cally
displays the kernel release information. This command is commonly
used in Linux systems to quickly check the kernel version running on the
system.
A. Crontab -display
B. Crontab -d
C. List --crontab
D. Crontab -l
Correct Answer
D. Crontab -l
Explanation
The correct answer is "crontab -l". This command is used to display the
current crontab entry. It lists all the scheduled tasks and their respective
timings.
A. Echo $UID
B. Id
C. Cat /etc/passwd
D. Cat /etc/groups
Correct Answer
B. Id
Explanation
The given answer "id" is correct because the "id" command is used to
display the user identity and group information. It provides information
such as the user ID (UID), group ID (GID), and the groups the user belongs
to. Therefore, running the "id" command would give you the required
information about your identity, including the names of the groups you
are in.
9. How do you run a job that will continue running even if you
are logged out?
A. Hup.out command
B. Hup command
C. Jobc command
D. Nohup command
Correct Answer
D. Nohup command
Explanation
The correct answer is "nohup command". The "nohup" command is used
to run a job in the background that will continue running even if the user
logs out. It stands for "no hangup" and is typically used to prevent a
process from being terminated when the user's terminal session ends. By
using the "nohup" command, the job is detached from the current
session and can run independently.
10. How do you see if two les are hard linked to each other?
A. Hl -l
B. Ln -s
C. Ls -i
D. Link -s
Correct Answer
C. Ls -i
Explanation
To see if two les are hard linked to each other, the "ls -i" command can
be used. The "-i" option displays the inode number of each le in the
directory listing. If two les have the same inode number, it means they
are hard linked to each other.
A. Crontab --create
B. Crontab -make
C. Crontab -e
D. Crontab -c
Correct Answer
C. Crontab -e
Explanation
To create a crontab entry, you would use the command "crontab -e". This
command allows you to edit the crontab le, where you can specify the
schedule and command for the desired task. The "-e" ag stands for
"edit" and opens the crontab le in a text editor, allowing you to make
changes to the existing entries or add new ones. This is the correct way
to create a crontab entry in most Unix-like operating systems.
A. Rm -i
B. Rm -chk
C. Rm -a
D. Rm -r
Correct Answer
A. Rm -i
Explanation
The correct answer is "rm -i". This command prompts the user for
con rmation before deleting each le, ensuring that les are not
accidentally removed without explicit permission.
A. Free -s 5
B. Top -m 5
C. Du -m 5
D. Mem -c 5
Correct Answer
A. Free -s 5
Explanation
The correct answer is "free -s 5". This command is used to display the
memory usage on a system. The "-s 5" option speci es that the memory
usage should be displayed every 5 seconds, providing a continuous
update on the memory usage.
A. Ps -C httpd
B. Ps -d httpd
C. Ps -r httpd
D. Ps -D httpd
Correct Answer
A. Ps -C httpd
Explanation
The correct answer is "ps -C httpd". This command is used to display the
running processes with the name "httpd". The "-C" option is used to
specify the process name, in this case, "httpd". This command will
provide a list of all the running httpd processes.
15. How would you nd out what your current login shell is?
A. Cat /etc/shell
B. Cat /etc/current/shell
C. Ps | grep sshd
D. Echo $$SHELL
Correct Answer
D. Echo $$SHELL
Explanation
To nd out the current login shell, the correct command is "echo
$$SHELL". The command "echo" is used to display the value of a shell
variable, and "$$" is a special variable that represents the current process
ID. By appending "SHELL" to "$$", the command will display the value of
the "SHELL" variable, which represents the current login shell.
16. How would you list oldest les rst and newest ones last?
A. Ls /o-d
B. Ls -od
C. Ls -rt
D. Ls -dt
Correct Answer
C. Ls -rt
Explanation
The command "ls -rt" is the correct answer because it uses the "-r" ag to
reverse the order of the listing and the "-t" ag to sort the les by
modi cation time, with the oldest les appearing rst and the newest
ones appearing last. This command will list the les in the desired order.
17. How would you lock the user account named csm099?
A. Usermod -l csm099
B. Usermod -L csm099
Correct Answer
B. Usermod -L csm099
Explanation
The correct answer is usermod -L csm099. The "-L" option in the usermod
command is used to lock a user account. By using this option followed
by the username "csm099", the user account named csm099 will be
locked.
A. Rm -r
B. Rm -f
C. Rmdir -f
D. Rmdir -le
Correct Answer
A. Rm -r
Explanation
To remove a directory that is not empty, you would use the command "rm
-r". The "-r" ag stands for "recursive", which means that it will remove not
only the speci ed directory but also all its contents, including
subdirectories and les. This command is necessary because the "rmdir"
command only works for empty directories, and the "-f" ag with "rm" is
used to forcefully remove les or directories without prompting for
con rmation. Therefore, "rm -r" is the appropriate command to remove a
non-empty directory.
A. Ps -ef -tree
B. Ps -ef --f
C. Ps -ef --forest
D. Ps -ef -t
Correct Answer
C. Ps -ef --forest
Explanation
The correct answer is "ps -ef --forest" because the "--forest" option is
used to display the process hierarchy in a tree-like format. This command
will show all the processes in a hierarchical structure, making it easier to
understand the relationship between different processes. The "ps -ef"
part of the command is used to display all the processes in a detailed
format, including the process ID, parent process ID, CPU usage, and
more.
A. Sort -n 3 shopping
B. Sort -k 3 shopping
C. Sort -c 3 shopping
Correct Answer
B. Sort -k 3 shopping
Explanation
The correct answer is "sort -k 3 shopping".
The "-k" option in the sort command is used to specify the key or column
number to sort the le on. In this case, we want to sort the le "shopping"
based on column 3. Therefore, the correct command would be "sort -k 3
shopping".
A. Ctrl+Alt+F1
B. Alt+F1
C. Ctrl+F1
D. Shift+Ctrl+F1
Correct Answer
A. Ctrl+Alt+F1
Explanation
To switch to virtual terminal 1, you would use the key combination
Ctrl+Alt+F1. This combination allows you to access a separate terminal
session, which can be useful for troubleshooting or running commands
without interfering with the graphical user interface. The Ctrl+Alt+F1
combination is a common shortcut in Linux-based operating systems for
switching to the rst virtual terminal.
22. How would you turn on the sticky bit on the directory
/tmp?
Correct Answer
D. Chmod o+t /temp
Explanation
The correct answer is "chmod o+t /temp". The sticky bit is a permission
that can be set on a directory to allow only the owner of a le within that
directory to delete or rename the le. In this case, the command "chmod
o+t /temp" is used to turn on the sticky bit on the directory /temp,
allowing only the owner of a le to modify it.
23. In which directory are the crontab les for users stored on
suse linux?
A. /var/spool/cron/tabs
B. /usr/lib/cron
C. /usr/bin/cron/crontabs
D. /var/spool/cron/users/tabs
Correct Answer
A. /var/spool/cron/tabs
Explanation
The correct answer is /var/spool/cron/tabs. This directory is where the
crontab les for users are stored on SUSE Linux. The crontab les
contain the schedules and commands for the cron daemon to execute at
speci ed times. Storing them in this directory allows the cron daemon to
easily access and manage the crontab les for each user.
A. /dev/stdin
B. /dev/stdout
C. /dev/stderr
D. /dev/hdal
Correct Answer
A. /dev/stdin
Explanation
The correct answer is /dev/stdin. In Unix-like operating systems,
/dev/stdin is a special le that represents the standard input. When the
cat command is used with a minus sign as an argument, it reads data
from the standard input, which can be redirected from a le or entered
directly from the keyboard.
25.
Suppose you are in your home directory, /home/raf as in
diagram above. What is the relative path for the le called
"save" in the Email subdirectory?
A. Raf/email/save
B. /email/save
C. /home/raf/email/save
D. Email/save
Correct Answer
D. Email/save
Explanation
The relative path for the le called "save" in the Email subdirectory is
"email/save". This is because the current directory is already "/home/raf",
so we don't need to include it in the relative path. We simply need to
navigate to the "Email" subdirectory and then access the "save" le within
it.
A. Chattr +i
B. Attrib +i
C. Imod +a
D. Chmod +i
Correct Answer
A. Chattr +i
Explanation
The correct answer is "chattr +i". The chattr command in Linux is used to
change le attributes. The +i option is used to set the immutable
attribute on a le, which means the le cannot be modi ed, deleted, or
renamed. This attribute provides an extra layer of protection for
important les.
A. 754
B. 724
C. 624
D. 742
Correct Answer
A. 754
Explanation
The permission string "nvxr-xr--" corresponds with the octal value 754. In
octal representation, each digit represents the permissions for different
user groups. The rst digit (7) represents the permissions for the owner,
the second digit (5) represents the permissions for the group, and the
third digit (4) represents the permissions for others. In this case, the
owner has read, write, and execute permissions (7), the group has read
and execute permissions (5), and others have only read permissions (4).
Correct Answer
D. Send error messages from command to a le called /dev/null
Explanation
The syntax "2> /dev/null" is used to send error messages from a
command to a le called /dev/null. The "2" represents the standard error
stream, and the "> /dev/null" redirects that stream to the le /dev/null,
which is a special le that discards any data written to it. By using this
syntax, any error messages generated by the command will be sent to
/dev/null and effectively discarded.
29. What symbol is used to show that ACLs have been set on
a le?
A.
B. +
C. ~
D. >
Correct Answer
B. +
Explanation
The symbol "+" is used to show that ACLs (Access Control Lists) have
been set on a le. ACLs are used to de ne permissions and access rights
for different users or groups on a le or directory. The "+" symbol
indicates that additional permissions beyond the traditional owner, group,
and other permissions have been assigned to the le.
A. Fc 40
B. Hs 40
C. Rc 40
D. Er 40
Correct Answer
A. Fc 40
Explanation
The command "fc 40" can be used to edit and then run command number
40.
A. Runlevel --settings
B. Status --l
C. Services --runlevels
D. Chkcon g --list
Correct Answer
D. Chkcon g --list
Explanation
The command "chkcon g --list" displays the settings for all services at all
runlevels. This command is commonly used in Linux systems to view the
status and con guration of services. It provides a comprehensive list of
services along with their current runlevel settings, allowing users to
easily manage and troubleshoot services on their system.
A. Dmount
B. Dismount
C. Unmount
D. Umount
Correct Answer
D. Umount
Explanation
The correct command used to unmount a lesystem is "umount". This
command is used to detach a mounted lesystem from its mount point,
allowing the device or partition to be accessed by other processes or to
be safely removed.
A. /etc/init/runlevels
B. /etc/levels/fstab
C. /etc/fstab
D. /etc/inittab
Correct Answer
D. /etc/inittab
Explanation
The correct answer is /etc/inittab. This le is responsible for determining
what processes or services will run at each run level in a Unix or Linux
system. It contains the con guration settings for the init process, which
is the rst process that is started during the boot process and is
responsible for starting and managing other processes. The /etc/inittab
le speci es which programs should be run at each run level, allowing
the system administrator to de ne different sets of processes to be
started depending on the desired run level.
A. Chmod +i
B. Immut +a
C. Attrib +i
D. Chattr +i
Correct Answer
D. Chattr +i
Explanation
The command "chattr +i" can be used to set the immutable attribute on a
le. This command is used in Linux systems to change the attributes of a
le or directory. The "+i" option speci cally sets the immutable attribute,
which prevents the le from being modi ed or deleted even by the root
user. This attribute provides an extra layer of security and ensures that
critical les remain unchanged.
A. Rw
B. Noexec
C. Ndev
D. Defaults
Correct Answer
C. Ndev
Explanation
The option "ndev" cannot be used as a mount option in /etc/fstab. This is
because "ndev" is not a valid mount option. The correct options that can
be used in /etc/fstab are "rw" (read-write), "noexec" (do not allow
execution of binaries), and "defaults" (use default mount options).
However, "ndev" is not a recognized mount option and therefore cannot
be used in /etc/fstab.
36. Which of the following could you use to check if the cron
daemon is running?
A. Service --status-all
B. Ps -list --daemons
D. Cron --status
Correct Answer
A. Service --status-all
Explanation
You can use the command "service --status-all" to check if the cron
daemon is running. This command displays the status of all services,
including the cron daemon.
A. Runlevel 2
B. Runlevel 3
C. Runlevel 0
D. Runlevel 1
Correct Answer
B. Runlevel 3
Explanation
Runlevel 3 allows full multiuser mode but with no graphical login
manager. In this runlevel, the system boots into a text-based console and
allows multiple users to log in and use the system simultaneously.
However, there is no graphical interface or login manager present, which
means users have to use command-line interfaces for all interactions
with the system. This runlevel is often used in server environments where
a graphical interface is not required or desired.
A. Runlevel 1
B. Runlevel 2
C. Runlevel 3
D. Runlevel 0
Correct Answer
C. Runlevel 3
Explanation
Runlevel 3 allows full multiuser mode but with no graphical login
manager. In this runlevel, the system boots into a multiuser mode with a
command line interface, allowing multiple users to log in and use the
system simultaneously. However, there is no graphical login manager
present in this runlevel, so users cannot log in through a graphical user
interface.
A. 1
B. 19
C. 9
D. 18
Correct Answer
B. 19
Explanation
The signal number that corresponds with the SIGSTOP signal is 19.
A. .bashtr
B. .linux_term
C. .term_win
D. .bashrc
Correct Answer
D. .bashrc
Explanation
The correct answer is .bashrc. This le is a script that is executed every
time a new terminal window is opened. By editing this le, you can add
commands or messages that you want to display when a new terminal
window is opened.
Related Topics
Recent Quizzes
How Much Do You Know The Ultimate Linux Hardest Linux Exam Quiz!
Linux? Commands And
Networking Test
Basic Linux Quiz: Hyperledger FABRIC Quiz Linux Certi cation Practice
Knowledge Trivia! Quiz
Featured Quizzes
Back to top