Advertise with Us!
We have a variety of advertising options which would give your courses an instant visibility to a very large set of developers, designers and data scientists.View Plans
Top Linux Interview Questions
Table of Contents
Linux is not just an operating system. Instead, it is a humongous family of free and open-source software operating systems that are based on the Linux kernel.
System security and Linux administration go hand to hand. So, expect Linux questions coming your way when interviewed for a security-based job profile.
Top Linux Interview Questions
Here, we have brought together a list of top Linux interview questions that you must know if your potential job opportunity encompasses Linux in any way.
Question: Can you tell us about the basic components of Linux?
Answer: Like any other typical operating system, Linux has an application program, GUIs, kernel, and shells. The main advantage of using Linux as an operating system lies in the fact that it is open source and heavily customizable, which makes it equally ideal to use for seasoned professionals as well as newcomers.
Question: Please draw a comparison between BASH and DOS.
Answer: DOS stands for Disk Operating System, while BASH is a contraction of Bourne Again Shell. A shell is simply a user interface meant for accessing the services offered by an operating system. It can either use a CLI, a GUI or both.
Following are the notable differences between DOS and BASH:
- Case Sensitivity – While DOS commands are not case sensitive, BASH commands are.
- Use of / and \ - In BASH, / acts as a directory separator and \ acts as an escape character. The use of / in DOS is to serve as a command argument delimiter and \ serves the role of directory separator.
- Naming Convention – DOS follows the naming convention under which a file must have an 8-character filename followed by a dot and 3-character extension. No naming convention is available for BASH.
Question: How will you check out how much memory Linux is using?
Answer: From the command shell, use the concatenate command:
This will give an output like this:
Mem: “some number in bytes”
Question: Please explain symbolic links in Linux.
Answer: Symbolic links point to directories, files, and programs in Linux. They allow gaining instant access to the object they are pointing without the need to traverse the entire path. Hence, symbolic links are like shortcuts in Windows.
Question: Can you tell us about the various kinds of permission under Linux? Also, explain how to change permissions.
Answer: There are three types of permissions under Linux:
- Read – Users are allowed to read the files or list the directory
- Write – Users are allowed to write to the file or add new files to the directory
- Execute – Users are allowed to run the file or lookup for a specific file within a directory
A system administrator or the owner of the file or directory can grant permission to others using the chmod command. It is followed by specifying the receiver(s) of the permission followed by whether permission is granted or denied, then type of permission, and finally having the name of the file.
The general syntax is something like this:
chmod permissionreceiver+typeofpermissions file
The permission receiver can be a for all, g for group, o for others, and u for the user. Typeofpermissions can be r for read, w for write, and x for executing. For instance, a command:
chmod go+rwx DemoFile.TXT
will grant read, write, and execute permission to group and others for the file named DemoFile.
Question: Please explain the virtual desktop and how to share a program across different virtual desktops under Linux.
Answer: Simply, a virtual desktop presents an alternative to minimizing and maximizing different windows. Instead of minimizing or restoring different programs, virtual desktops allow shuffling between desktops having different program windows.
Many times there is a need to share a program across different virtual desktops. For doing so, simply go to the upper left corner of the program window and click on the pushpin-like icon. It will pin the application, making it accessible across all the virtual desktops.
Question: What do you understand by daemons?
Answer: Daemons are a way of extending the functionality of the base operating system. In other words, daemons are services that offer several functions that might not be available in the operating system.
The main task of a daemon is to actively listen for a service request and to act upon them at the very same time. Once it completes the service, a daemon gets disconnected and waits for further requests.
Question: Please explain the various modes when using the vi editor.
Answer: The vi editor offers 3 modes:
- Command Mode – This is the mode where the user starts
- Edit Mode – This mode allows to do the text editing
- Ex Mode – This mode allows interacting with vi, allowing executing instructions to process a file
Question: What are the contents of /usr/local?
Answer: The /usr/local directory contains the locally installed files. The importance of the directory is when files are stored on some network. Moreover, the directory is used for storing software packages installed from a source or software not officially accompanying the distribution.
Question: Tell us how you will execute more than one command or program from a single command line entry.
Answer: Linux allows for combining several commands in a single line. Each of the commands is separated by a semicolon (:). The execution is carried in the order the commands are specified, from left to right.
Question: What do you mean by hard links in Linux?
Answer: Hard links in Linux point directly to the physical file present on the disk. It doesn’t concern the pathname. It simply means that in case the file is renamed or moved to some other location, the link will not break and will still function like before.
Question: Please explain case-sensitivity issues in Linux.
Answer: Sometimes entering the same command in Linux results in different outputs. This is typically attributed to case sensitivity. Because Linux is case sensitive, a command that previously produced the desired output might not do the same when executed again.
For example, the ls command is responsible for listing all files in the directory. However, entering LS, lS, or Ls will display an error. Moreover, if there is a program that is named LS, then entering the LS command will execute it rather than listing all files in the directory.
Question: Can you tell what does a nameless directory represents in Linux?
Answer: The empty directory name serves as the nameless base of the Linux file system. It serves as an attachment for all other devices, directories, drives, and files present on the system.
Question: Can you draw the Linux architecture?
Question: Please explain how to enable curl on Ubuntu LAMP stack and root logging in Ubuntu?
Answer: To enable curl on Ubuntu LAMP stack:
- Install libcurl
- Use the command:sudo/etc/init .d /apache2 restartORsudo service apache2 restart
To enable root logging in Ubuntu, use the command:
#sudo sh-c 'echo "greater-show-manual-login=true" >>/etc/lightdm/lightdm.conf'
Question: How will you append one file to another in Linux?
Answer: The command:
cat file1 > file2
appends two files in Linux. You can append as many files using the command. For example, to append three files, named file1, file2, and file3, we can use the command:
cat file1 > file2 > file3
Another way of appending one file to another in Linux is by using the command:
The >> operator appends the output of the named files.
Question: What command would you use for editing, searching, and replacing text in Linux?
You can use the cd command followed by the name of the text editor, like vi, with which you need to edit the file.
You can search a file in Linux by using the command:
find –iname “filename”
For searching and printing text in a file in Linux, you can use the command grep.
This procedure involves using the Stream Editor (sed). You need to use the command:
sed -i 's/old-text/new-text/g' input.txt
Enter the text that needs to be replaced in place of the old-text and the new text that needs to be added in place of the new-text.
Question: What do you understand by swap space in Linux?
Answer: The swap space comes into play when the RAM doesn’t have enough memory to hold all programs that are currently executing. The swap space is some memory space used by the Linux operating system to temporarily hold programs that are running concurrently.
Question: Please explain how you will run a Linux program in the background together with starting the Linux Server.
Answer: You need to use the nohup command first. It will stop the process receiving the NOHUP signal. The termination will log you out of the program that was invoked. Then start the Linux server, and enter the name of the Linux program followed by the & symbol to run the process in the background.
Question: Can you explain how to remotely login with SSH?
Answer: Although there are many ways of accessing a remote computer, using the SSH (Secure SHell) protocol is widely preferred. The protocol makes use of a public-key cryptography authentication method for securing communication between the hosts.
For using the SSH command, the user needs to define the server by entering its IP address. If 192.168.100.22 is the IP address of the system to which the SSH access is needed then enter the command:
Also, you can specify the explicit username as:
SSH allows for data compression as well as sending graphical commands via X11. When configured correctly, the SSH protocol provides a secure line that is capable of protecting itself against DNS spoofing and man-in-the-middle attacks.
Question: Please explain the checking for Rootkit infections in Linux.
Answer: A Rootkit is an advanced form of malware that can yield a range of security issues and in many cases go undetected by average antivirus programs. Hence, advanced anti-spyware tools need to be used for checking Rootkit infections in Linux. One such is the rkhunter.
Rkhunter can be installed from the software repository by following the instructions of your distribution’s package management. Debian and Ubuntu users can use the (sudo) apt-get install rkhunter command while Red Hat-based distributions can use either the dnf or yum command.
A few other notable security tools available for checking rootkit infections in Linux are:
- LMD (Linux Malware Detect)
Question: How will you setup Password Aging in Linux?
Answer: The chage command allows the system administrators in Linux to enforce password aging. The command is used to change the number of days between mandatory password resets. The /etc/login.defs file is responsible for handling system-wide configuration. It can be edited for:
- PASS_MAX_DAYS – Defines the maximum number of days a password may be used.
- PASS_MIN_DAYS – Defines the minimum number of days allowed between password changes.
- PASS_WARN_AGE – Defines the number of days warning is given before a password expires.
That completes the list of the important Linux interview questions. Hope these questions will help you clear that upcoming Linux interview.
Check out some of the best Linux system administration tutorials. What questions you were expecting weren’t there on the list? Are there any wrong answers given? Let us know via the comments window below.
People are also reading: