Linux Interview Questions

Preparing for a Linux interview in a short time is not a challenge anymore. Here are some popular Linux interview questions to get you through. Bridge your knowledge gap with the top linux interview questions and answers for experienced and freshers listed here that discusses topics like the difference between Unix and Linux, usage of different commands in Linux, etc. and get hired as a Linux administrator, cloud administrator and similar profiles.Once you are prepared with these tricky interview questions, you will be able to pass the toughest of Linux interviews easily.

  • 4.5 Rating
  • 22 Question(s)
  • 25 Mins of Read
  • 9848 Reader(s)


Unix is an Operating System and Linux is mainly a Kernel for Linux Based OS.
Linux is a Unix-Like based OS, it means the core functionalities behind is similar to UNIX OS.
Unix is an operating system having some common command as that of Linux.
Linux is an operating system having some common command as that of Unix.
Unix uses Command Line Interface.
Linux uses Graphical User Interface with an optional Command Line Interface.
Unix is mainly used in Server Systems, Mainframes and High-End Computers
Linux is mainly used in Home Based PC, Mobile Phones, Desktops, etc.
Unix has a rigid requirement of the Hardware. Hence, cannot be installed on every other machine.
Linux is very flexible and can be installed on most of the Home Based Pcs.
Different Versions of Unix are: AIS, HP-UX, BSD, Iris, etc.
Different Versions of Linux are: Ubuntu, Debian, OpenSuse, Redhat, Solaris, etc.
Both Unix are written in C & Assembly language.
Both Linux are written in C & Assembly language.

Type any one of the following command to find os name and version in Linux:

cat /etc/os-release
lsb_release -a 

Example –

% hostnamectl
Static hostname: WDFL41000139D
Icon name: computer-vm
Chassis: vm
Machine ID: bfc98d9a56631ccde8f8578d58347195
Boot ID: dc39baafe82849b39413507cfd395b54
Virtualization: microsoft
Operating System: SUSE Linux Enterprise Server 12 SP2
CPE OS Name: cpe:/o:suse:sles:12:sp2
Kernel: Linux 4.4.121-92.98-default
Architecture: x86-64
%lsb_release -a
LSB Version: n/a
Distributor ID: SUSE
Description:  SUSE Linux Enterprise Server 12 SP2
Release:    12.2
Codename:   n/a

Also type the following command to find Linux kernel version:

uname -r

ps (i.e., process status) command is used to provide information about the currently running processes, including their PIDs (process identification numbers). A process is a running  instance of a program. Every process is assigned a unique PID by the.

$ ps -ef
$ ps -ef | grep tomcat

All the files and directories in Linux  have below 3 permissions, represented by a three digit octal value .-

Read -    It provides the ability to read the contents of a file (represented by 'r' in the first position "r--")

Write -   It Provides the ability to edit or delete the content of a file (represented by 'r' in the second position "-w-")

Execute - It Provides the ability to execute the file (represented by 'x' in the third position "--x")

The octal value is calculated as the sum of the permissions:

“read” is 4

“write” is 2

“execute” is 1


From the command shell, use the command for memory usage information :

cat /proc/meminfo

Ex :

% cat /proc/meminfo 
MemTotal: 16250912 kB 
MemFree: 3281056 kB 
MemAvailable: 10404492 kB
Buffers: 1101852 kB
Cached: 4654684 kB
SwapCached: 129304 kB
Active: 7930860 kB
Inactive: 2892144 kB
Active(anon): 4118480 kB
Inactive(anon): 1197660 kB
Active(file): 3812380 kB
Inactive(file): 1694484 kB
Unevictable: 236 kB

There are other commands also which gives memory info :

free - m

To list every occurrence of the term “warn” on a separate line,

run grep -o warn <path>. Adding the r flag to the command makes recursive search for every file under the given path, and the I flag ensures that matches in binary files are ignored.

In addition, the w flag can be included to match the exact term only, and ignore superstrings such as “warnings”, and to make the search case-insensitive, the i flag can be added.

% grep -iworI warn | wc -l 

In Linux, Curl command is a tool to transfer data from or to a server. In Linux, curl command is used to test an application's endpoint or connectivity to an upstream service endpoint. It is used to determine if the application can reach another service, like a database, or to check if the service is up and running . This  command doesn’t require any user interaction.


$ curl -I -s application:5000

This example with an exception shows that the application can't reach server. Options used In the above command,

-I option -> shows the header information
-s option -> silences the response body.

Curl command with -O option is  used to download the file :

Usage :

curl -O #Save the file as tar,gz
Hard link
Soft link
Hard link associates two (or more) filenames with an inode.
Soft link is a special file type which points to another file and the contents of this special file is the name of the file that it points to.
Hard links all share the same disk data blocks while functioning as independent directory entries.
Soft links are created by the - ln -s command.
Hard links may not span disk partitions since inode numbers are only unique within a given device.
Once a file which is pointed to by a symbolic link is deleted, the link still points to it, leaving a hanging link
Command to create a hard link to ‘knowledgehut’ is:
$ ln knowledgehut hlink
Command to create a symbolic link to ‘knowledgehut’ :
$ ln -s  knowledgehut slink

SED command in UNIX stands for stream editor, which is used to make changes to file content.

It can be used to find and replace strings or patterns without opening a file

The default behavior is that  the SED command replaces the first occurrence of a pattern in each and it won’t replace the second, third or multiple occurrence in the line.

If we use the ‘g’ option along with the above command then SED command will replace all Unix strings with Linux globally ( g stands for globally) .

sed 's/unix/linux/g' sample.txt
sed '/^$/d' sample.txt

Here “^” symbol represents the starting point of a line and “$” represents the end of the line. Whereas “^$” represents the empty lines , d stands for delete .

Top is the command used to get the list of running processes and resource utilization (RAM or CPU usage). It gives  all the information about each process running on the host :

  • Process ID (PID)
  • Owner of the process(USER)
  • Priority of process(PR)
  • Percentage of CPU (%CPU)
  • Percentage of memory
  • Total CPU time spends on the process.
  • Command used to start a process.

Sample Output :

7629 greys     20 0 749m 291m  28m S 1 7.4 16:51.40 firefox
19935 greys     20 0 133m 14m  10m S 0 0.4 2:38.52 smplayer
   1 root      20 0 4020  880 592 S 0  0.0 0:00.96 init
   2 root      15 -5 0    0 0 S 0 0.0   0:00.00 khutreadd
   3 root      RT -5 0    0 0 S 0 0.0   0:00.04 datamigration/0
   4 root      15 -5 0    0 0 S 0 0.0   0:00.90 ksoftirqd/0
   5 root      RT -5 0    0 0 S 0 0.0   0:00.00 watchdog/0
   6 root      RT -5 0    0 0 S 0 0.0   0:00.06 datamigration/1

Most commonly used options with the top  command are below –

top -u -> Process by a user.
top – i -> exclude idle tasks
top -p -> Show a particular process

lsof -  ‘LiSt Open Files’ is used to find out which files are opened or are in use .

Example :

# lsof -u kunand


sshd    1838 kunand  mem REG   253,0 122436 190247 /lib/

sshd    1838 kunand  mem REG   253,0 255968 190256 /lib/

sshd    1838 kunand  mem REG   253,0 874580 190255 /lib/

Zombie process is a process whose execution is completed but have not been removed from the process table.

When a program forks and the child finishes before the parent , kernel has some of the child information .

In case parent needs to check for child's exit status - parent calls 'wait()'. Child is said to be a zombie process in the duration child terminating and the parent calling 'wait()'.

Execute the below command

ps aux | grep Z  

child will have a 'Z' in its status field to indicate zombie process

Also this command will give details of all zombie processes in the processes table.

As zombie processes are already dead , the user  Cannot kill something which is already dead.

Execute the below command :

kill -s SIGCHLD pid

Replace the pid with Parent process ID, so that parent process will remove all the child processes that are dead.

This can be checked by using du command ( disk usage)

du –sh . | grep G    - lists all the directory which has GIGS in Size.

$ du –sh . | grep G

5       ./Default/AppData/Local/Microsoft/Windows/WinX/Group1

25      ./Default/AppData/Local/Microsoft/Windows/WinX/Group2

60      ./Default/AppData/Local/Microsoft/Windows/WinX/Group3

Below commands can be used :

nslookup - to find the IP address from a hostname or vice-versa.

ipconfig or ifconfig - based on whether the host is Windows or Unix

hostname -i - on Linux

touch command is used to create an empty filename

Example :

$ touch knowledgehut.txt

Also for existing files or directories, touch command changes the last access time to current time.

Head command is used to display first few lines (default is 10) of the file.
Tail is used to display last few lines(default is 10) of the file .

#Display first 10 lines of the file - application.log

head application.log

#Display first 50 lines of the file - application.log

head -50 application.log

#Display last 10 lines of the file - application.log

tail application.log

#Display last 50 lines of the file - application.log

tail -50 application.log

This can be done using 'sed' command :

# Here 'p' to print and '-n' to not print each line

sed -n 10,20p input.txt > output.txt

This can be done using wc command (word count)-

#Number of lines

$ wc -l knowledgehut.txt
4 knowledgehut.txt

#Number of words 

$ wc -w knowledgehut.txt
3 knowledgehut.txt

#Number of characters 

$ wc -m knowledgehut.txt
19 knowledgehut.txt

Aliases are abbreviated shortcuts used to represent a command or a group of commands executed with or without custom options.

#Alias for log directory

alias logs="cd /user/application/logs"

These aliases can be put in the ~/.bash_aliases file.

To have the aliased command on any existing terminal, user needs to source ~/.bashrc from the terminal :

source ~/.bashrc

Below are the system calls used for Process management:

fork () :- create a child process

exec() :- Execute a new program

wait():- wait until the process finishes execution

exit():- Exit from the process

getpid():- get the unique process id of the process

getppid():- get the parent process unique id

nice():- run a program with modified scheduling priority

LILO is a boot loader for Linux. LILO stands for Linux Loader that is used to load Linux into memory.

It is used mainly to load the Linux operating system into main memory so as to begin operation.

Lilo handles some tasks such as locating the kernel, identifying other supporting programs, load memory and starts the kernel. The configuration file of lilo is located at “/etc/lilo.conf”. Lilo reads this configuration file and it tells Lilo where to place the bootloader.

find –perm option is used to find files based on permissions

Here "." or period denotes the current directory

$ find . -perm 777







Linux is a free and open-source operating system which is based on Linux kernel, which was first released on September 17, 1991. In Linux, users can create modifications and variations of the source code for computers and other devices, which are known as distributions. It is most commonly used as a server, but also used in desktop computers, e-book readers, smartphones, etc.

The most popular Linux distributions are Fedora, ubuntu and Debian, which the common commercial distributions include Red Hat Enterprise Linux and SUSE Linux Enterprise Server.

Professionals can opt for jobs as Linux administrator, cloud administrator, etc once they have an in-depth understanding of the core Linux concepts. According to, a Linux Administrator has an average base salary of $92,115, with their base salary ranging from $73,345 to $103,894.

Top companies from around the globe run on Linux, to name a few companies Google, Twitter, Facebook, Amazon, IBM, etc.

Are you planning to get into a reputed organization? Then have a glance at these Linux interview questions and answers. Linux is one of the best-known operating systems. Linux jobs are the best choice to magnify your skills. Learning Linux with these interview questions and answers will help you fetch the best jobs in the market.

If you are looking to crack Linux job interview we have built Linux job interview questions and answers page to ensure an outstanding performance in the interview. To keep a track of all your dream jobs, you can also visit our website for more information.

These basic Linux interview questions will be an added advantage to crack your next Linux interview. We have different series of Linux interview questions and answers for experienced and freshers for your interview based on basic and advanced levels. So, prepare better with our extensive list of Linux interview questions. Our advanced Linux interview questions will not only help you prepare for the interview but will also enable you to manage difficult projects with ease.

Read More