Top 30 Linux Interview Questions And Answers: 2020 | OdinSchool

Top 30 Linux Interview Questions And Answers: 2020 | OdinSchool


This blog discusses essential concepts and questions related to Linux for interviews. It covers the definition of LINUX as an open-source operating system, highlighting its features such as customization, multiple file systems, and strong immunity against viruses. The blog also outlines crucial features like portability, multitasking, secure authentication, and hierarchical file systems. It presents 30 Linux interview questions, including differences between UNIX and LINUX, details about LILO (Linux Loader), explanation of "Swap Space," and concepts like Zombie Processes, Process States, and more. Additionally, it explains commands like "grep," disc usage checking with "df" and "du," permissions management, ownership settings, and other important Linux commands. The content emphasizes the significance of understanding these topics for successful Linux interviews.

In the Linux interview, you are expected to know about Linux in detail. If asked, LINUX is an open-source operating system where one gets the liberty to design their custom Operating System. It’s free software with free server licensing and can be installed on multiple computers depending upon the requirement. It supports multiple file systems, and the immunity toward viruses and malware is very high.

Features of the LINUX operating system

  • It is portable.
  • It supports simultaneous functionality and is multitasking.
  • Offers secure Authentication, Authorization, and Encryption.
  • It allows multiple users to access the same system resource (using different terminals for operation).
  • A hierarchical file system is available.
  • Its code is freely available. It’s Open Source
  • Has its own application support to download and install applications.
  • Customized keyboards.
  • Multiprocessor (SMP) Support
  • Virtual Memory
  • Graphical User Interface (X Window System, Wayland)
  • Wide Hardware Support
  • Dynamically Linked Shared Libraries as well as Static Libraries
  • POSIX Compliant (Almost)
  • Multiple Virtual Consoles
  • Multiple Filesystem Support
  • Multiple Networking Protocols (TCP/IP, IPX/SPX, Appletalk, AX.25)
  • Shell
  • Strong Security Model

Top 30 questions to Ace Linux interview

1. What is the difference between UNIX and LINUX?

The major differences are:

  • Unix was created in the late 1960s at AT&T Bell Labs whereas Linux was built by Linus Torvalds at the University of Helsinki in 1991.
  • Unix originally began as a proprietary operating system from Bell Laboratories, which later on spawned into different commercial versions. It is used in Intel, HP, internet servers, etc. whereas Linux is a free, open-source software development and intended as a non-proprietary operating system for the masses. Linux is a free operating system used for computer hardware & software, game development, PCs, etc
  • Unix was developed for mainframes, servers, and workstations except for OS X which is designed such that it can be used by any File support system that includes jfs, gpfs, hfs, etc. but for Linux, Users of this operating system could be anyone including home users, developers, etc. File support system includes Ext2, Ext3, Ext4, Jfs, Xfs, Btrfs, FAT, etc.
  • Different versions of Unix are available with different price structures whereas Linux has priced as well as freely distributed and downloaded versions.
  • Unix, the source code is proprietary, whereas Linux source code is available to the general public.
  • Unix is a full-fledged operating system, whereas Linux is just a kernel of many free operating systems like Arch Linux, Fedora, GNU Sense, Linux Mint, Red Hat, Ubuntu, etc. 

2. What is “LILO”?

LILO stands for “Linux Loader”. It is a Loader used to quickly access the operating system’s library, which in turn makes Linux a fast OS. It is the Linux Boot Loader that loads the Linux Operating System into the main memory to begin execution. Windows or Mac OS come with its bootloader, but while using Linux, one needs to install a special bootloader.

Once the computer is powered on, after the BIOS conducts the initial tests, the control is transferred to the Master Boot Record, and the  LILO loads the Linux OS and starts it. 

3. Explain what is “Swap Space”?

It is just a temporary amount of memory space on Linux that is created to allow a certain program to run smoothly. Once the program has finished running, the swap space is also no more.

4. What is a “Zombie Process”?

It is a process that completes its execution but still can be found in the process table. Zombie processes usually occur for child processes, as the parent process still needs to read its child's exit status.

5. How to swap the “stdout” and “stderr” of a command?

$ command 3>&2 2>&1 1>&3

Here a third file descriptor is being created (in this case 3), which is assigned to the same target that stderr is pointed to (referenced by &2). Then stderr is pointed to the same target and stdout is pointed to (&1). Finally, stdout is pointed back to where the newly created file descriptor is pointed (which is the same target stderr is originally pointed to.)

6. What is “Inodes” in Linux?

The “Inode” or “Index node” in a data structure is a Unix style file system that describes a file system object such as a file system or a directory. An inode is a unique name given by the operating system to each file. Similarly, a process id is a unique id given to each process.

When a file is created, it is assigned both, a name and an inode number. It is an integer that is unique within the file system.

7. Define the Components of Linux.

Main components of Linux are

  • Kernel: this is the core of Linux. It is responsible for interacting with hardware components.
  • Shell: it is an interface between a Linux user and the Kernel. User issues command in a shell.
  • System Libraries.
  • System Utilities.

8. How do you create and delete directories in Linux?

  • For creation:  mkdir <directory name>
  • For removing empty directories: rmdir <name of the directory> or rm -d <name of the directory>
  • To remove non-empty directories and all the files within them: rm -r <name of the directory>

9. How to create a file?

Touch and Cat commands are used.:

  • touch <file name>
  • cat <file-name>

10. How to rename files and directories?

Example: mv /data/files/file1.doc <space> /data/files/file2.doc

This will rename file1.doc to file2.doc.

12. How to schedule a task in Linux?

The Cron daemon is a program that executes commands at a specific date and time in Linux.

13. What is Crontab? Explain fields in Crontab.

A Crontab is similar to a task scheduler on windows. Adding tasks to your system’s crontab files with the use of appropriate syntax and Cron automatically runs them for the user.

Crontab files are effectively used to perform automated backups, system maintenance, and other repetitive tasks. It is a powerful and very flexible syntax, so you can have a task run every fifteen minutes or at a specific minute on a specific day every year. Crontab files are not intended to be edited directly, few command-line options for crontab are:

  • Crontab -e (edit your crontab file)
  • Crontab -l (show crontab file)
  • Crontab -r (remove file)

14. Explain GREP.

It stands for “Global Regulation Expression Point”, used for filtering results or output.

This command is used to search for a text in a file by pattern matching based on a regular expression.

Syntax: grep [options] pattern [files]

Example: $ grep -c "data" sales.txt

This command will print the count of the word “data” in the “sales.txt” file.

How would you count every occurrence of the term “there” in all the files appearing under the current directories, and its subdirectories, recursively?

$ grep -orI there . | wc -l

To list every occurrence of the term “there” on a separate line, one must run grep -o there <path>. Adding the r flag to the command makes the search recursively process every file under the given path, and the I flag ensures that matches in binary files are ignored. Also, the w flag can be included to match the exact term only, and ignore superstrings such as “there”, and to make the search case-insensitive, the i flag can be added as well:

$ grep -iworI there . | wc -l

The number of lines yielded by this grep command is the number of occurrences of the desired term, which can then be counted by piping it into the wc -l command.

(Note: in the above question the interviewer can ask you for any word “there” is just an example word to explain the process to count the occurrence of any word in all the files appearing under the current directories, and its subdirectories, recursively). 

15.  What is Process State in Linux?

 Refers to the current state that s Linux process is in. there are generally four states :

  • Running
  • Waiting
  • Stopped
  • Zombie

16. How to stop a running process?

To do so “kill” to kill a process by id or “killall” to kill a process by name, commands are used.

  • kill process-id
  • killall process-name

17. How to check disc usage in Linux?

  • “df” and “du” are used.
  • “df” this command checks the used and remaining space on your hard drive.
  • “du” this command checks the hard drive usage by specific files or directories.

18. How to set Linux file/directory permissions?

The Command “chmod” is used. Here “r” is for reading, “w” is for write, and “x” is for executing.

  • chmod +x filename to allow executable permissions.
  • chmod +rwx filename to add permissions.
  • chmod -rwx directory name to remove permissions.
  • chmod -wx filename to take out write and executable permissions.

19. How to set ownership for files or directories?

The chown command is used.

  • chown user: user file name (to set file owner)
  • chown -R user: user directory name (to set a directory owner)

Note: -R is used to assign permissions recursively.

20. What is “whoami” command?

This command means “who am I?”. It shows current login and user information.

21. How would you write a shell script and ensure that only one instance of the script may run for every user? 

In Bash:


if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then

echo "Already running!"

exit 1


trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT

echo $$ > ${LOCKFILE}

First, determine a name for the lock file. Here, the lock file is generated by suffixing a common name with the username of the current user. Now, check if the lock file exists and if the PID contained within the lock file is running. If it is, exit with a message.

Create a trap to remove the lock file on a clean exit, or unclean exits (any exit with the signal INT or TERM). Finally, if the script has not exited yet, create the lock file, and store the PID of the current process ($$) in it.

22. What is a hard link?

A hard link is another name for the physically existing files on the disk in Linux, or other operating systems such as Unix and not on the pathname.  There can be multiple numbers of hard links therefore there can be multiple numbers of any file. Also if, if the original file is renamed or moved, the link will not break as the link is for the file, not for the path where the file is located. Hard links have a special feature of having the ability to be created for other hard links.

23. What are the environmental variables?

Environmental variables also known as global shell variables are a set of dynamic named values stored within the system. It can be defined as a variable with a name and an associated value. These are global settings that control the shell's function as well as that of other Linux programs and are used by applications launched in shells or subshells. 

24. What is BASH?

Bourne Again SHell. It was written as a replacement to the original Bourne Shell (represented by /bin/sh) by Steve Bourne. It has additional functions combined with all the features from the original version of Bourne Shell that makes it easier and more convenient to use. It is used as a default shell for most systems running Linux.

25. Which are the Shells that are used in Linux?

Linux uses various shells for its functioning. A few mostly used Shells are 

  • csh: C shell. As the name suggests, it follows a syntax, same as C and provides job control and spelling corrections.
  • ksh: Korn Shell (it is a high-level programming shell).
  • fish: Friendly interactive shell helps in providing auto-suggestions, web-based configuration, and clean scripts. 
  • bash: Bourne Again Shell( a default shell function for Linux).
  • zsh: Z shell provides filename generation, watches login and logout, closing comments, startup files, etc.

26. What is a virtual desktop?

Virtual Desktop refers to creating a virtual screen allowing the users to use the desktop beyond the physical limits of the normal screen. Virtual Desktop can be implemented in two different ways:

  • Switching Desktops.
  • Oversized desktops.


Switching Desktops

Oversized Desktops


One or multiple, discrete virtual desktop is used to run programs

The user is allowed to scroll around a larger desktop than the actual screen. 


Each virtual desktop behaves as an individual desktop

No such feature is available


The user using a particular desktop has access to the programs running on that desktop only.

There is only one larger desktop.

27. What are “System Calls”?

System calls work as the fundamental interface between the application and Linux Kernel. This is how a program enters the kernel to perform a given task. Just like library wrapper functions, system calls are generally not invoked directly but via wrapper functions in other libraries such as Glibc. System calls are used by the programs to perform various operations, including creating processes, doing network and file IO, etc.

28. What are “Symbolic links” in Linux?

Popularly known as soft links, perform functions similar to “shortcuts” in windows. A special feature file points to another file. A symbolic link does not contain any data from the target file. It just points to another entry located somewhere else in the file system.

Steps to view symbolic links in a directory:

  • Open a terminal and move to that directory.
  • Type the command: ls -la. This lists all the files in the directory, including the hidden ones.
  • Any file that starts with l is a symbolic link file.

29. What do you mean by “cd command” in Linux”?

When working with the Linux terminal, the Change Directory command is the most basic and frequently used. To change the current working directory in Linux or any other operating system similar to Unix. Its behavior may vary from shell to shell as this command is a shell built-in command as it uses shell environmental variables to access required information for its execution.

30. Name a few directory commands in Linux.

Various directory commands used in Linux and their functions are:

Directory Command



Displays the present working directory


Lists the content of a directory.

ls -la

List all the content of a directory including the hidden files and directories


Creates a new directory

mkdir -p

Creates nested directories.


Removes or deletes an existing directory, provided it is empty.


Changes directory.

cd . .

Takes the user one level up the directory tree.

touch file name

Creates a new file.

rm filename

Deletes a file

rm -f filename

Forcefully deletes a file.

rm -r directory

Deletes a directory recursively along with its content.

rm -rf directory

Forcefully and recursively deletes a directory along with its content.

cp file1 file2

Copies the content of file file1 into file file2.

cp -r dir1 dir2

Copies the content of file dir1 into file dir2.


Renames the files and directories. Or moves files and directories

cat filename

Prints the content of a file

head filename

Prints the first 10 lines of the file.

tail filename

Prints the last 10 lines of a file.

tail -f filename

Prints the last 10 lines of a file and will keep printing new lines as they get appended to the file.




About the Author

Meet Misha Thakur, a talented writer who enjoys baking and taking pictures in addition to contributing insightful articles. She contributes a plethora of knowledge to our blog with years of experience and skill.

Join OdinSchool to upskill your career

With Job Assistance

View Course