Akhil Bhadwal | 28 Mar, 2023

Top Linux Interview Questions and Answers


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 and Answers

Here, we have brought together a list of top Linux interview questions and answers 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:

  1. Case Sensitivity – While DOS commands are not case sensitive, BASH commands are.
  2. 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.
  3. 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:

cat /proc/meminfo

This will give an output like this:

Mem: “some number in bytes”

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.

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?
Answer: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:

  1. Install libcurl
  2. 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:

cat file2>>file1

The >> operator appends the output of the named files.

Question: What command would you use for editing, searching, and replacing text in Linux?

Answer:

Editing:

You can use the cd command followed by the name of the text editor, like vi, with which you need to edit the file.

Searching:

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.

Replacing:

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:

ssh 192.168.100.22

Also, you can specify the explicit username as:

ssh someusername@192.168.100.22

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:

  • Chkrootkit
  • ClamAV
  • LMD (Linux Malware Detect)
  • Lynis

Question: Define Linux?

Answer: Linux is an operating system which is based on UNIX. It can run on various platforms that are manufactured by Intel, HP, IBM, Motorola, SPARC, and MIPS. The mascot of Linux is a Penguin from Tux Paint.

Question: Is there any difference between UNIX and LINUX?

Answer: There is a huge difference between UNIX and LINUX. UNIX is a propriety operating system of Bell Laboratories which developed its commercial versions. LINUX, on the other hand, is a completely free and open-source operating system meant for the common masses.

Question: Define the LINUX Kernel?

Answer: LINUX Kernel is the name given to the low-level systems software which can manage different hardware resources for the users. It helps in providing an interface for the user-level interaction.

Question: What is LILO in LINUX?

Answer: LILO is a name given to the bootload in the LINUX. Its function is to load the LINUX operating system into the main memory so that the operating system can be initiated.

Question: What are the advantages of an open-source?

Answer: There are various advantages of an open-source which includes:

  1. It helps in distributing the software carrying its source codes freely to the users.
  2. It supports the users to add new features, debug, and correct errors in the source code.
  3. It helps in redistributing the new, improved source code back again free of cost to other users.

Question: What are the differences between the BASH and DOS commands?

Answer: There are several differences between the BASH and DOS commands, which include the following:

BASH

DOS

It is case sensitive.

It is not case sensitive.

Character act as a directory separator and escape character.

It helps as a command argument delimiter and directory separator as well.

It follows no conventions.

It follows the convention in naming files, which has eight characters as the file name followed by a dot and three characters in the extension.

Question: What are the advantages of the GNU project?

Answer: The GNU project is a free software that offers various advantages as follows.

  1. It offers the freedom to run the programs for any purpose.
  2. It helps in studying and modifying the program as per the user needs.
  3. It allows the redistribution of copies of the software to people.
  4. It helps in improving the software.
  5. It supports the release of the software to the public.

Question: What is a Root Account?

Answer: A Root Account is a system administrator account which helps in applying complete control over the system. It helps in creating and maintaining various user accounts and thereby assign them different kinds of permissions as per each account. It occurs by default whenever LINUX is installed.

Question: What is the full form of CLI and GUI?

Answer: CLI stands for Command Line Interface, and GUI stands for Graphical User Interface.

Question: Explain CLI?

Answer: CLI is an interface that allows the users to type various kinds of declarative commands which are meant to instruct the computer so that it could perform its particular functions. It offers greater flexibility to the users.

Question: Explain GUI?

Answer: GUI helps in making use of images and icons so that the users can click and manipulate the way of communication with the computer. It helps in removing dependence over type commands and supports graphical elements representation to interact with the system.

Question: How can we open a command prompt in LINUX?

Answer: We can open the command prompt when issuing a command by pressing Ctrl+Alt+F1. It will help in providing a Command Line Interface (CLI) where the commands can be run as per the needs.

Question: Can we find how much memory LINUX is using?

Answer: Yes, we can find how much memory LINUX is using. It can be done by applying a command shell, namely "Concatenate" command by applying cat/proc/meminfo. This will help in the display of memory usage. The outcome is in the form of Mem:12345678 etc. This outcome is the memory that LINUX has to offer you as available for usage.

Question: What is the size of a Swap Partition in LINUX?

Answer: The size of the Swap Partition in LINUX is double the amount of the physical memory available with the system. The minimum size is, however, the amount of memory installed.

Question: How does Ctrl+Alt+Del key combination work in LINUX?

Answer: The Ctrl+Alt+Del key combination works in LINUX, just like it works in Windows. This key combination helps in restarting the system. However, in LINUX, there is no confirmation message displayed earlier to the restart, and the reboot occurs immediately.

Question: How can we refer to the parallel ports in LINUX?

Answer: The parallel ports include the printers, scanners, and various other electronic devices attached to the computer system. In Linux, these parallel ports are referred to as /dev/lp0 for LPT1, /dev/lp1 for LPT2, and so on.

Question: How are drives represented in LINUX?

Answer: Drives such as floppy drives, hard drive, and others are not represented in drive letters but with different designations such as /dev/fd0 or fd1 for floppy drives 1 and 2. For hard drives, it is referred to as /dev/hda or hdb or hdc, etc.

Question: What is a pwd command in LINUX?

Answer: pwd stands for print working directory. This command is used for printing the working directory.

Question: Are there any Environmental variables in LINUX?

Answer: Yes, there are various environmental variables in LINUX, which include shell function, which is also known as global shell variables.

Question: Define Redirection in LINUX?

Answer: The Redirection in LINUX is the process that directs the data from one output to another. It can be used as a direct input to another process to get the desired output.

Question: Define the Grep command?

Answer: Grep command is used as a search command so that the specific pattern-based search can be initiated. It helps in using various options and parameters that are along with the command line so that the required file output can be attained.

Question: Can we terminate an ongoing process in LINUX?

Answer: Yes, we can terminate an ongoing process in LINUX by using the Kill command, which is followed by the pid to terminate the particular process. The use of Kill 0 can be made to terminate all processes.

Question: Can we insert comments in the command line prompt?

Answer: Yes, we can insert comments in the command line prompt by typing the #symbol before the actual comment text. The shell will, therefore, ignore what is written, and the comment will be shown.

Question: How can we apply command grouping in LINUX?

Answer: Command grouping can be applied in LINUX by placing parenthesis to the group commands.

Question: Can we uninstall the libraries in LINUX?

Answer: Yes, we can uninstall the libraries in LINUX by using command sudo apt-get remove library_name.

QuestionHow 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.

Summary

That completes the list of the important Linux interview questions. I hope these questions will help you clear that upcoming Linux interview.

If you are looking for more in-depth preparation before your interview, Linux Technical Interview Questions is a highly rated course on udemy.

There is also a pocketbook available for brushing up on all the basic Linux commands, relevant for 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:

By Akhil Bhadwal

A Computer Science graduate interested in mixing up imagination and knowledge into enticing words. Been in the big bad world of content writing since 2014. In his free time, Akhil likes to play cards, do guitar jam, and write weird fiction.

View all post by the author

Subscribe to our Newsletter for Articles, News, & Jobs.

I accept the Terms and Conditions.
Thanks for subscribing! Look out for our welcome email to verify your email and get our free newsletters.

Disclosure: Hackr.io is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission.

In this article

Learn More

Please login to leave comments