We are Hiring Tech Content Writers (Freelancer/Full-Time). Are you interested? Apply Now

22 Essential Linux Interview Questions

Linux Interview Questions

Hackr.io.

Spread the love

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.

Linux Interview Questions

Here, we have brought together a list of 22 important Linux interview questions that you must know if your potential job opportunity encompasses Linux in any way.

Q: Can you tell us about the basic components of Linux?
A: 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.

Q: Please draw a comparison between BASH and DOS.
A: 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.

Q: How will you check out how much memory Linux is using?
A: From the command shell, use the concatenate command:

cat /proc/meminfo

This will give an output like this:

Mem: “some number in bytes”

Q: Please explain symbolic links in Linux.
A: 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.

Q: Can you tell us about the various kinds of permission under Linux? Also, explain how to change permissions.
A: 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 permissionreceiver can be a for all, g for group, o for others, and u for user. Typeofpermissions can be r for read, w for write, and x for execute. 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.

Q: Please explain the virtual desktop and how to share a program across different virtual desktops under Linux.
A: 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.

Q: What do you understand by daemons?
A: 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.

Q: Please explain the various modes when using vi editor.
A: 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

Q: What are the contents of /usr/local?
A: 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.

Q: Tell us how you will execute more than one command or program from a single command line entry.
A: 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.

Q: What do you mean by hard links in Linux?

A: 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.

Q: Please explain case sensitivity issues in Linux.
A: 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.

Q: Can you tell what does a nameless directory represent in Linux?
A: 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.

Q: Can you draw the Linux architecture?
A:Linux Architecture

Q: Please explain how to enable curl on Ubuntu LAMP stack and root logging in Ubuntu?
A: 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’

Q: How will you append one file to another in Linux?
A: 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.

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

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.

Q: What do you understand by swap space in Linux?
A: 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.

Q: Please explain how you will run a Linux program in the background together with starting the Linux Server.

A: 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.

Q: Can you explain how to remote login with SSH?
A: 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.

Q: Please explain checking for Rootkit infections in Linux.
A: 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

Q: How will you setup Password Aging in Linux?
A: 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 22 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.

Related Posts

Your email address will not be published. Required fields are marked *

*