Every Linux OS has four primary components: Kernel, Shells, System Utils, and Application Programs. However, mostly we use to interact with the Shells and Linux commands to get on to the tasks. Hence, we bring you 30 Linux questions on essential OS concepts and frequently used commands.
Especially in this quiz, we’ve assembled thirty situation-based questions on Linux commands. In each question, you’ll be asked to select a command that can fit in the given scenario.
For example, you might run into a case where you’ll have to leave but run a program in the background. Alternatively, the program has to throw all errors and output to a single file. In some other scenarios, you may have to copy the final logs to a remote machine after finishing a task.
These types of Linux questions are useful in the sense that they’ll make you think about the real-time usage of the OS commands.
By the way, if you are one of a shell scripting freak, then do attempt this Unix Shell scripting quiz.
Learning all Linux commands isn’t as easy as remembering the alphabet. One can only keep them memorized by mapping them to a palpable situation. Hence, we wrote a dedicated post covering essential Linux commands which you can use as a quick reference.
30 Linux Questions With Answers – Online Test
Answer Key with Reasoning
Here’s a concise reasoning table explaining the correct answers for all 30 Linux-related questions.
Q# | Correct Answer | Reasoning |
---|---|---|
1 | uname -r | uname -r prints the kernel version, while other commands are incorrect. |
2 | ls -Z | ls -Z lists files along with their security context (SELinux labels). |
3 | shutdown -h now, poweroff | Both commands immediately shut down the system. shutdown -h now is more commonly used. |
4 | gpasswd -r | gpasswd -r removes a group’s password, unlike passwd commands, which are for user passwords. |
5 | tar tvf file.tar | tar tvf lists the contents of a tar file without extracting it. |
6 | shadow | /etc/shadow stores encrypted passwords, providing extra security. |
7 | ls -rt | ls -rt sorts files by modification time, oldest first. |
8 | Create home directory | useradd does not create a home directory unless -m is specified. |
9 | Password field blank | In /etc/passwd , an empty password field means authentication uses shadow passwords. |
10 | Username, UID, GID, shell | /etc/passwd contains username, UID, GID, home directory, shell, and comments. |
11 | ps -ef --forest | ps -ef --forest displays processes in a tree format. |
12 | fc 10 | fc 10 opens the 10th command in an editor for modification and execution. |
13 | chmod o+t /tmp | The o+t flag sets the sticky bit, preventing users from deleting others’ files in /tmp . |
14 | /dev/stdin | cat - reads input from stdin (/dev/stdin ). |
15 | .bashrc | .bashrc executes when a new terminal session starts, setting up the environment. |
16 | Ctrl+D | Ctrl+D sends an EOF signal, closing the terminal session. |
17 | /etc/passwd | /etc/passwd lists all system users along with their details. |
18 | command > file 2>&1 | This redirects both stdout and stderr to the same file. |
19 | rm -rf | rm -rf forcefully deletes non-empty directories, unlike rmdir , which only removes empty ones. |
20 | Discard stderr | 2> /dev/null discards error messages by redirecting stderr to /dev/null . |
21 | echo $SHELL | echo $SHELL prints the default shell for the user. |
22 | Ctrl+Alt+F1 | Ctrl+Alt+F1 switches to virtual terminal 1 in a Linux GUI system. |
23 | ps -C httpd | ps -C httpd lists all running httpd (Apache) processes. |
24 | !! | !! repeats the last executed command. |
25 | id | id displays the current user’s UID and GID. |
26 | usermod -L localusr | usermod -L locks a user account by disabling its password. |
27 | /etc/inittab | /etc/inittab defines system runlevels in older Linux distributions (SysV init). |
28 | rw-r--r-- | 644 means read-write for the owner and read-only for others. |
29 | chmod 544 file | 544 sets r-xr--r-- , allowing only the owner to execute. |
30 | ls -a | ls -a lists all files, including hidden ones (files starting with . ). |
Key Takeaways from the Linux Quiz
We hope that you would have enjoyed solving each and every question of this online Linux quiz. The knowledge that you would gain from here is not only relevant in the interviews, but you can also use it in handling real-time tasks. Those who have recently started playing with Linux can go through the below post and learn even more.
Also Read: Linux Interview Questions and Answers
Before we conclude for the day, let’s listen to an interesting quote about Linux. It highlights why it’s counted as the best Server operating system.
It’s a bird. It’s a plane. No, it’s Kernel Man, faster than a speeding bullet, to your rescue.
It was none other than the Linus Torvalds who said this in his speech while announcing a new Kernel release.
Keep Learning,
TechBeamers