linux interview questions

In this part of Linux Interview Questions, we will discuss the most common theoretical and concept-based questions.

1. What is Linux?

Linux is an Open-Source Operating System based on Unix. Linux was first introduced by Linus Torvalds. The main purpose of Linux was to provide free and low-cost Operating Systems for users who could not afford Operating Systems like Windows or iOS or Unix.

2. What is the difference between Linux and Unix?

The main differences between Linux and UNIX are as follows:

Parameter Linux Unix
Price Both free distributions and paid distributions are available. Different levels of UNIX have a different cost structure
Target User Everyone (Home user, Developer, etc.) Mainly Internet Server, Workstations, Mainframes.
File System Support Ext2, Ext3, Ext4, Jfs, ReiserFS, Xfs, Btrfs, FAT, FAT32, NTFS. jfs, gpfs, hfs, hfs+, ufs, xfs, zfs,vxfs.
GUI KDE and Gnome Common Desktop Environment
Viruses listed 60-100 80-120
Bug Fix Speed Faster because Linux is Community driven Slow
Portability Yes No
Examples Ubuntu, Fedora, Red Hat, Kali Linux, Debian, Archlinux, Android, etc. OS X, Solaris, All Linux

Linux vs. Unix – Linux Interview Questions

3. What is Linux Kernel? Is it legal to edit Linux Kernel?

Linux kernel refers to the low-level system software. It is used to manage resources and provide an interface for user interaction.

Yes, it is legal to edit Linux Kernel. Linux is released under the General Public License (General Public License). Any project released under GPL can be modified and edited by the end-users.

4. What is LILO?

LILO stands for Linux LOader. LILO is a Linux Boot Loader that loads Linux Operating System into the main memory to begin execution. Most of the computers come with boot loaders for certain versions of Windows or Mac OS. So, when you want to use Linux OS, you need to install a special boot loader for it. LILO is one such boot loader.

When the computer is started, BIOS conducts some initial tests and transfers control to the Master Boot Record. From here, LILO loads the Linux OS and starts it.

The advantage of using LILO is that it allows fast boot of Linux OS.

5. What are the basic components of Linux?

The basic components of Linux are:

  • Kernel: It is the core component of the Operating System that manages operations and hardware.
  • Shell: Shell is a Linux interpreter which is used to execute commands.
  • GUIGUI stands for Graphical User Interface which is another way for a user to interact with the system. But unlike CLI, GUI consists of Images, Buttons, TextBoxes for interaction.
  • System Utilities: These are the software functions that allow the user to manage the computer.
  • Application Programs: Software programs or sets of functions designed to accomplish a specific task.

6. Which are the Shells used in Linux?

The most common Shells used in Linux are

  • bash: Bourne Again Shell is the default for most of the Linux distributions
  • ksh: Korn Shell is a high-level programming language shell
  • csh: C Shell follows C like syntax and provides spelling correction and Job Control
  • zsh: Z Shell provides some unique features such as filename generation, startup files, login/logout watching, closing comments etc.
  • fish: Friendly Interactive Shell provides some special features like web-based configuration, auto-suggestions, fully scriptable with clean scripts

7. What is Swap Space?

Swap Space is the additional space used by Linux that temporarily holds concurrently running programs when the RAM does not have enough space to hold the programs. When you run a program, it resides on the RAM so that the processor can fetch data quickly. Suppose you are running more programs than the RAM can hold, then these running programs are stored in the Swap Space. The processor will now look for data in the RAM and the Swap Space.

Swap Space is used as an extension of RAM by Linux.

8. What is the difference between BASH and DOS?

There are 3 main differences between BASH and DOS:

Sl. no. BASH DOS
1. Commands are case-sensitive. Commands are not case-sensitive.
2. ‘/’ (forward slash) is used as a directory separator.

 (backslash) is used as an escape character.

‘/’ (forward slash) is used as a command argument delimiter.

 (backslash) is used as a directory separator.

3. Follows naming convention: 8 characters for file name postfixed with 3 characters for the extension. No naming convention.

Bash vs Dos – Linux Interview Questions

9. What command would you use to check how much memory is being used by Linux?

You can use any of the following commands:

  • free -m
  • vmstat
  • top
  • htop

10. Explain file permission in Linux.

There are 3 kinds of permission in Linux:

  1. Read: Allows a user to open and read the file
  2. Write: Allows a user to open and modify the file
  3. Execute: Allows a user to run the file.

You can change the permission of a file or a directory using the chmodcommand. There are two modes of using the chmod command:

  1. Symbolic mode
  2. Absolute mode

Symbolic mode

The general syntax to change permission using Symbolic mode is as follows:

$ chmod <target>(+/-/=)<permission> <filename>

where <permissions> can be r: read; w: write; x: execute.

<target> can be u : user; g: group; o: other; a: all

'+' is used for adding permission

'-' is used for removing permission

'=' is used for setting the permission

For example, if you want to set the permission such that the user can read, write, and execute it and members of your group can read and execute it, and others may only read it.

Then the command for this will be:

$ chmod u=rwx,g=rx,o=r filename

Absolute mode

The general syntax to change permission using Absolute mode is as follows:

$ chmod <permission> filename

The Absolute mode follows octal representation. The leftmost digit is for the user, the middle digit is for the user group and the rightmost digit is for all.

Below is the table that explains the meaning of the digits that can be used and their effect.

0 No permission – – –
1 Execute permission – – x
2 Write permission – w –
3 Execute and write permission: 1 (execute) + 2 (write) = 3 – wx
4 Read permission r – –
5 Read and execute permission: 4 (read) + 1 (execute) = 5 r – x
6 Read and write permission: 4 (read) + 2 (write) = 6 rw –
7 All permissions: 4 (read) + 2 (write) + 1 (execute) = 7 rwx

For example, if you want to set the permission such that the user can read, write, and execute it and members of your group can read and execute it, and others may only read it.

Then the command for this will be:

$ chmod 754 filename

11. What are inode and process id?

inode is the unique name given by the operating system to each file. Similarly, the process id is the unique id given to each process.

12. Which are the Linux Directory Commands?

There are 5 main Directory Commands in Linux:

pwd: Displays the path of the present working directory.

Syntax: $ pwd

ls: Lists all the files and directories in the present working directory.

Syntax: $ ls

cd: Used to change the present working directory.

Syntax: $ cd <path to new directory>

mkdir: Creates a new directory

Syntax: $ mkdir <name (and path if required) of new directory>

rmdir: Deletes a directory

Syntax: $ rmdir <name (and path if required) of directory>

13. What is Virtual Desktop?

Virtual Desktop is a feature that allows users to use the desktop beyond the physical limits of the screen. Basically, Virtual Desktop creates a virtual screen to expand the limitation of the normal screen.

There are two ways Virtual Desktop can be implemented:

  1. Switching Desktops
  2. Oversized Desktops

Switching Desktops

In the case of Switching Desktops, you can create discrete virtual desktops to run programs. Here, each virtual desktop will behave as an individual desktop and the programs running on each of these desktops is accessible only to the users who are using that particular desktop.

Oversized Desktops

Oversized Desktops do not offer a discrete virtual desktop but it allows the user to pan and scroll around the desktop that is larger in size than the physical screen.

14. Which are the different modes of vi editor?

There are 3 modes of vi editors:

  1. Regular/Command mode: This Lets you view the content
  2. Insertion/edit mode: This lets you delete or insert content
  3. Replacement mode: Lets you overwrite content

15. What are daemons?

A daemon is a computer program that runs as a background process to provide functions that might not be available in the base Operating System. Daemons are usually used to run services in the background without directly being in control of interactive users. The purpose of Daemons is to handle periodic requests and then forward the requests to appropriate programs for execution.

16. What are the process states in Linux?

The process states are as follows:

  • Ready: The process is created and is ready to run
  • Running: The process is being executed
  • Blocked or wait: Process is waiting for input from the user
  • Terminated or Completed: Process completed execution, or was terminated by the Operating System
  • Zombie: Process terminated, but the information still exists in the process table.

17. Explain the grep command.

Grep stands for Global Regular Expression Print. The grep command is used to search for a text in a file by pattern matching based on a regular expression.

Syntaxgrep [options] pattern [files]


$ grep -c "linux" interview.txt

This command will print the count of the word “Linux” in the “interview.txt” file.

18. Explain Process Management System Calls in Linux

The System Calls to manage the process are:

  • fork () : Used to create a new process
  • exec() : Execute a new program
  • wait() : Wait until the process finishes execution
  • exit() : Exit from the process

And the System Calls used to get Process ID are:

  • getpid():- get the unique process id of the process
  • getppid():- get the parent process unique id

19. Explain the ‘ls’ command in Linux

The ls command is used to list the files in a specified directory. The general syntax is:

$ ls <options> <directory>

For example, if you want to list all the files in the Example directory, then the command will be as follows:

$ ls Example/

There are different options that can be used with the ls command. These options give additional information about the file/ folder. For example:

-l  lists long format (shows the permissions of the file)
-a  lists all files including hidden files
-i  lists files with their inode number
-s  lists files with their size
-S  lists files with their size and sorts the list by file size
-t  sorts the listed files by time and date

20. Explain the redirection operator.

The redirection operator is used to redirect the output of a particular command as an input to another command or file.

There are two ways of using this:

‘>’ overwrites the existing content of the file or creates a new file.

‘>>’ appends the new content to the end of the file or creates a new file.

21. Why is the tar command used?

The tar command is used to extract or create an archived file.

Suppose you want to extract all the files from the archive named sample.tar.gz, then the command will be:

$ tar -xvzf sample.tar.gz

Suppose you want to create an archive of all the files stored in the path /home/linux/, then the command will be:

$ tar -cvzf filename.tar.gz

where c: create an archive, x: extract, v: verbose, f: file

22. What is a Latch?

A Latch is a temporary storage device controlled by a timing signal which can either store 0 or 1. A Latch has two stable states (high-output or 1, and low-output or 0) and is mainly used to store state information. A Latch can store one bit of data as long as it is powered on.

23. What is a Microprocessor?

A Microprocessor is a device that executes instructions. It is a single-chip device that fetches the instruction from the memory, decodes it, and executes it. A Microprocessor can carry out 3 basic functions:

  1. Mathematical operations like addition, subtraction, multiplication, and division
  2. Move data from one memory location to another
  3. Make decisions based on conditions and jump to new different instructions based on the decision.


24. Explain Regular Expressions and Grep

Regular Expressions are used to search for data having a particular pattern. Some of the commands used with Regular Patterns are: tr, sed, vi, and grep.