The Definitive Guide to Linux Interview Questions

linux-interview-questions

Nowadays, almost every server or advanced system uses Linux because it is a powerful and fast operating system. Moreover, it is loved by techies. Therefore, the job role of a Linux administrator has now become a priority in many server-based organizations.

However, it is not easy to get these jobs because a person requires in-depth knowledge and information about Linux.

So if you also want to crack the interviews, then be sure to read this guide. In this guide, we will explain some of the most common Linux interview questions you can prepare, whether you are a beginner or an expert.

Table of Contents

Linux Interview Questions

In this section, we have included 40+ questions that can help you prepare and crack a Linux-based job interview with flying colors.

To help you better digest the content, we have divided it into basic Linux interview questions, intermediate-level Linux interview questions, and advanced Linux interview questions. Let’s start with the Linux interview questions for beginners.

Basic Linux Interview Questions

Q.1 What is Linux, and why is it used?

A.1 Linux was initially developed by Linus Torvalds and released on September 17, 1991, as a clone of Unix. Originally, Linux was a Kernel by which many popular distributions like Ubuntu, Fedora, CentOS, etc., developed. Linux is majorly preferred because it is:

  • Open-source
  • Free 
  • Secure
  • Portable

Q.2 What are the basic components of Linux?

A.2 The basic components that make up a Linux OS are:

  1. A shell
  2. A kernel
  3. Application programs
  4. System utilities
  5. A GUI [Optional]

Q.3 Explain the Linux file system.

A.3 The Linux file system is an underlying layer for storing and managing the data. It maintains the complete information of the file, like file size, filename, creation date, and so on. Also, the Linux file system helps organize the files on the storage.

Q.4 What is the Linux kernel? Can you customize it legally?

A.4 Linux was originally developed as a free replacement for Unix. Also, it was kept open-source. It refers to low-level system software that provides user interaction and resource management interfaces. It is possible for users to edit and modify any project released under GPL. Linux is released under the ‌Public License (GPL), so you can edit it legally.

Q.5 What is Bash?

A.5 Bash is a command language released in 1989 that also doubletimes as the Unix shell. It was developed by Brian Fox as the free replacement for the Bourne shell.

Bash is commonly available in various Linux distros as the default login shell. It is not a compiled and interpreted process that can run in a terminal window.

Q.6 Enumerate the differences between DOS and bash.

A.6 Here is the complete list of differences between DOS and dash:

ParametersDOSBash
DeveloperTim PatersonChet Ramey, Brian Fox (original author)
Command StructureCommands are not case-sensitiveCase-sensitive commands are present
File Naming ConventionsFollows conventions naming in files.Does not follow naming conventions in files.
Forward SlashIn DOS, the directories separator is represented by a forward slash.In BASH, the forward slash represents the escape character.
Backward SlashHere, the backward slash represents command arguments.The backward slash represents the directories separator.

Q.7 How is Unix different from Linux?

A.7 There happen to be several dissimilarities between the two popular operating systems. These are the most important differences between Linux and Unix:

LinuxUnix
Available in both free and paid versions.Available in a paid version only.
Commonly used on phones, PCs, laptops, and servers.Used in server systems only.
It is portable.It is not portable.
Linux’s default shell is Bash.Unix’s default shell is the Bourne shell.

Q.8 What do you understand about LILO? How does it work?

A.8 Linux loads the system into a primary memory to start execution. Windows and macOS versions often come with bootloaders, while Linux requires a special bootloader to start. LILO is one of these boot loaders.

Many popular Linux distributions currently use GRUB as the default boot loader. However, LILO and ELILO (LILO’s version) are still in use because LILO allows Linux OS to boot faster.

Q.9 What is a shell?

A.9 A shell in Linux is a command-line interpreter. It executes programs called commands by providing an interface between the kernel and the user.

Shells convert human-readable commands into kernel-comprehensible languages. Hence, you can use a shell to communicate with the kernel by writing commands, programs, and scripts.

Q.10 How many types of shells are available in Linux?

A.10 There are various types of shells in Linux, such as:

  • The Bourne Shell (sh): Steve Bourne originally introduced the Bourne shell in AT&T Bell Labs. Almost every Solaris system administration script contains the Bourne shell. Therefore, the Bourne shell is considered the first Unix shell.
  • The GNU Bourne-Again Shell (bash): Almost every Linux distro contains the bash shell as the pre-installed utility. Initially, the bash was intended to be a more advanced Bourne shell.
  • The Korn Shell (ksh): ksh was developed by David Korn at Bell Labs as a superset of Bourne’s shell. It supports everything that the Bourne shell does. Its interactive features include string manipulation and functions, C-like arrays, and built-in arithmetic.
  • The Z Shell (zsh): Z shell is the extension of the sh shell, and obviously, along with many improvements from the sh shell.
  • The Friendly Interactive Shell (Fish): This Linux shell is also designed to be interactive and user-friendly like other shells. It facilitates auto-suggestion, web-based configuration, et cetera.

Q.11 What are the pros and cons of an open-source project?

A.11 Linux is one of the oldest open-source operating systems. Like with all things, open-source projects have their advantages and issues. Here are the important ones:

Pros of Open-source Software

  • Developers worldwide can work in one place to provide free software.
  • A user has privileges to download an open-source software and change its code accordingly.
  • Open-source projects include many security-related options.

Cons of Open-source Software

  • Open-source projects have hidden costs and some compatibility issues.
  • It isn’t easy to use open-source software if a user doesn’t have the proper knowledge.

Q.12 Explain the difference between external and internal commands.

A.12 

External commandsInternal commands
Not built into the shell.Built into the shell.
Run through the kernel.Run directly through the shell.
Each command has its process ID.No separate process ID is required to run.

Q.13 What do you understand from a CLI and a GUI?

A.13 A CLI (Command-Line Interface) is a command language interpreter and a text-based UI. It interacts with computer programs and manages files by issuing text lines as commands, helps in running programs, and so on. A CLI is also known as a character user interface, console user interface, and command-line user interface.

A GUI (Graphical User Interface) combines textual interaction with a graphical interface. You can use a mouse to access menus, icons, images, windows, etc. because it has a simple UI like other utilities.

Q.14 Please explain the process management system calls.

A.14 Following are calls to the process management system that did not require a process ID:

fork():Creates a new process.
exec():Executes a new program.
exit():Ends the process.
wait():Waits for a process until execution.
nice():Biases the currently running process asset.

Here is the list of process management system calls that require a process id:

getpid():Finds the unique process ID.
getppid():Finds the parent process ID.

Q.15 What is the inode and process id in Linux?

A.15 Every file in Linux has a unique name, called an inode. Similarly, every process has a unique name, called a process id.

Q.16 vi editor has several modes that you can use. Explain them briefly.

A.16 vi editor is available in three modes:

  • Regular Mode/Command Mode: Any character you type during command mode is considered a command. You can copy, cut, paste or delete commands and move through the file because these characters are not visible in the editor.
  • Edit Mode/Insert Mode: You can type characters into this mode, and the system will add them to your text file.
  • Escape Mode: This mode is used to execute the commands and save the files.

Q.17 What is the procedure for deleting information from a file in vi?

A.17 In vi editors, you can delete the information in the following ways:

  • Type dd to delete the current line.
  • Input x to delete the character currently displayed.
  • Type dg to delete all texts and lines.

Q.18 What is VirtualBox?

A.18 VirtualBox is an open-source tool or hypervisor for managing multiple operating systems on a desktop. This tool allows you to run different operating systems by storing them on a remote server. VirtualBox is available on macOS, Linux, and Windows.

Q.19 Explain the root account in Linux.

A.19 The root account is a unique user with 0 UID (user ID) in the /etc/passwd file. A root user can perform various tasks such as changing file permissions and installing software, which you can not do as a regular user.

Q.20 How does PIPE work in Linux?

A.20 You can use PIPE in Linux to connect two or more commands. It sends the output of one program/process to another program/process as its input, i.e. PIPE transfers the standard output to another destination.

Intermediate-Level Linux Interview Questions

Q.21 What is a daemon?

A.21 The daemon is a unique background process that serves ‌other computers. It ensures that all the operating systems under their supervision are running properly. In many different forms, most operating systems use daemons.

Q.22 What is a stateless Linux server?

A.22 A stateless server in Linux is a centralized server, and no other state exists. In certain cases, the user may want all other machines to be in the same state as a snapshot of a particular system.

Q.23 Kindly explain symbolic and hard links.

A.23 A symbolic link or soft link in Linux is equivalent to a Windows shortcut. This link refers to any folder, file, or connected file system on your system. You can point to any directory, file, or other files. Therefore, soft links are like shortcuts.

A hard link is another file name in the Linux file system. Each of the files begins with a hard link available in the data in the filesystem and the filename. You can create many hard links for a file.

Q.24 What do you understand from environmental variables?

A.24 Environment variables are dynamic values that affect the behavior of programs on the system. Typically, they are stored in the operating system and used by applications launched in subshells and shells. These variables provide information about system behavior and can be edited, created, deleted, and saved.

Q.25 What is swap space in Linux?

A.25 The swap space is used when a physical memory RAM runs out of space. This utility stores inactive memory pages, but you can not use the swap space as a replacement for RAM.

Q.26 Explain the various types ‌of file permissions available in Linux.

A.26 Every directory and file in Linux contains three types of permissions.

  1. Read: Users with this permission can open and read files.
  2. Write: This permission allows the user to edit or modify the file.
  3. Execute: This permission is used to view and execute the directory file, affecting the user’s ability.

Q.27 Please explain LVM and its need in Linux.

A.27 LVM is a storage management device whose full name is Large Volume Management. It is mainly used to allocate logical units and group storage devices. This tool allows users to resize and delete LVM partitions as it enhances control, flexibility, and abstraction.

Q.28 What is umask?

A.28 In Linux, umask offers a user file creation mode. It specifies and controls the permissions of the default file of the new directory or file created by the user.

Q.29 Explain network bonding and name its different modes in Linux.

A.29 Network bonding combines two or more network interfaces to form a single one. It provides redundancy and improves performance by increasing network bandwidth. Here is the list of network bonding modes in Linux:

Q.30 How will you find which ports are listening on a Linux server?

A.30 To find out the listening ports in Linux, we need to follow these steps:

  • First‌, open the terminal.
  • You can find out the open ports running in Linux by running either the sudo netstat -tulpn | grep LISTEN or sudo lsof -i -P -n | grep LISTEN command.
  • In the latest version of Linux, you can check the open ports using the ss command. For example: ss -tulw

Q.31 List the commands to check the default route and routing table in Linux.

A.31 You can display the route and routing table in Linux using the following commands:

  • $ netstat -rn
  • $ route -n
  • $ ip

Q.32 What is the process for changing the Linux default run level?

A.32 Linux users can change the run level in Linux by editing /etc/inittab using the init command and changing their default run level.

Q.33 Where are the kernel modules located?

A.33 The modprobe command is used to load and unload the kernel modules in Linux. These kernel modules are located in /usr/lib/modules/kernel-version/ or /lib/module/kernel-version/ by default. The extension of these kernel modules is .ko, which means ‘kernel object.’

Q.34 What is the procedure for locking a user account in Linux?

A.34 It is necessary to lock the user account from a security point of view so that no other unauthorized users can log in. You can lock your user account ‌with these different methods:

  • Use the nologin command to change the shell (/sbin/nologin).
  • Terminating a user account using the change command or the usermod command.
  • Finally, disable or lock the password with the passwd command.

Q.35 What is the grep command?

A.35 The grep command in Linux works as a filter to search any specific pattern across the files and directories. This command prints the file name, a colon, and the line matching the pattern when a particular pattern is available in a directory.

Q.36 Explain the process of sharing a directory using NFS.

A.36 Sharing a directory with the help of NFS is very easy. To share a directory using NFS, follow these steps:

  • First, go to /etc/export and edit the configuration file.
  • Once this happens, enter the directory name like this: /<directory-name>
  • Restart NFS after completing the above steps.

Q.37 What is the tail command?

A.37 The tail command prints the last N lines of the provided data. This command prints the last 10 lines by default. It is also possible to change the number of lines using -n. Moreover, you can specify -<number> to display a different number of lines.

Q.38 What is the env command?

A.38 A Unix-like operating system, like Linux, uses env as a shell command. This command is used to run other utilities in a changing environment without modifying the currently existing environment. Furthermore, this Linux command also lists environment variables.

Q.39 Explain the netstat command.

A.39 The netstat command in Linux displays protocol and network status statistics by generating a display. You can display different information related to interface, routing table information, and TCP or UDP endpoints in the table format.

Q.40 Why is lsof used in Linux?

A.40 Isof is primarily used to list open files. You can use this command to display information about the opened files and the source utility that launched these files.

Expert Linux Interview Questions

Q.41 What is the procedure for removing a file or directory from the Linux system?

A.41 You can delete empty directories in Linux using the following commands:

$ rmdir <directory name>

$ rm-d <directory name>

You can remove the non-empty directory with the rm command with -r recursively. For example:

$ rm-r <directory name>

Q.42 What is the ps command in Linux?

A.42 The ps command identifies the programs running on the Linux system and their resources. It displays memory, CPU, I/O activity, thread ID or process status information, and current statistics on the system.

Q.43 Explain the top command.

A.43 The top (table of processes) command in Linux shows a real-time view of currently running processes. This command also shows resource usage, including memory and CPU usage, as a system information summary.

Q.44 What are chmod and chown commands in Linux?

A.44 The chmod command is used to change the permissions of directories and files. Mainly, it has three parameters: read, write and execute, represented by numbers 4, 2, and 1, respectively.

The chown command changes the ownership of files for a group or user in Linux. Hence, you can use this command to change the group and owner of the file.

Q.45 How is the mkdir command different from the rmdir command?

A.45 mkdir is a contraction for ‘make a directory,’ which allows users to create one or more directories simultaneously and set their permissions. In contrast, the rmdir command is used to remove the same directories.

Q.46 Which Linux distributions (distros) are popular and why?

A.46 There are different types of Linux distros available for specific users, and some of the most popular ones are: 

  • Ubuntu: Based on Debian, Ubuntu is available for both server editions and desktops.
  • Linux Mint: It is a robust and stable Linux distribution using cinnamon and MATE desktops.
  • Debian: This distribution is user-friendly, characterized by user-to-user stability, strength, and a well-maintained release cycle.

Q.47 Explain the commands to edit the contents of a file.

A.47 There are many Linux commands that can help you with editing the contents of a file. Some of the most popular ones are listed below:

CommandsFeatures
headDisplays the starting of the file.
lessDisplays contents in a pager form (in a more human-readable and proper format).
tailDisplays the end part of the file.
tacThis command is the opposite of the cat command.
catThis command is multi-worker and versatile.

Q.48 What are the basic commands in Linux?

A.48 There are multiple types of Linux commands, such as pwd, cd, ls, cp, cat, mkdir, mv, etc. These commands can be used to perform different tasks right from the terminal. Therefore, you can use these Linux commands to increase productivity.

In a Nutshell

So this was a list of the most popular Linux interview questions you can learn to crack any job in the Linux field. These questions help interviewers to assess the knowledge of a Linux user.

The first twenty questions are for a beginner, the next twenty are for intermediate-level Linux users, and the rest are for a Linux expert. All the best!

Share Your Thoughts, Queries and Suggestions!