Linux interview questions for beginners

Prepare for Linux interview with our comprehensive list of over 50 interview questions. These interview questions are specifically designed for freshers.

Ques.1. What is UNIX?

Ans. UNIX is a multi-user multi-tasking computer operating system developed at Bell Laboratories by Ken Thompson and Dennis Ritchie. It is a proprietary software with its code not available to the general public.
The different variants of UNIX are HP Unix, Solaris Unix, IBM AIX and BSD.

Ques.2. What is Linux?

Ans. Linux is an open source UNIX like operating system developed from scratch by Linus Trovald. Although Linux is actually a different operating system but since it is inspired from UNIX, the commands and syntax of UNIX and Linux programs are mostly similar.
Some of the Linux distributions are Ubuntu, RedHat, Fedora etc.

Ques.3. What are some basic features of Linux?

Ans. Some of the features of Linux are-

  1. Multiuser - The multiuser feature of Linux provides it the ability to let multiple users access the same computer resources like memory, application programs, hard disk etc at the same time.
  2. Multitasking - Multitasking allows multiple applications or programs to run simultaneously.
  3. Security - Linux provides security feature by authentication(username-password for users), authorization(by providing read-write-execute permissions to different files), encryption(by encrypting files so that only the rightful owner can see the original content of the files).
  4. Portable - Linux supports portability with the ability of the OS to get installed in different hardware platforms.
  5. Open source - Its open source with its code available to general public.

Ques.4. What is the difference between UNIX and Linux?


1. UNIX is a proprietary operating system. Linux is an open source operating system.
2. Different vendors of UNIX operating system has different cost of the distributions. Most of distributions of Linux are free distributed but also has paid distributions.
3. Distributions - HP Unix, Solaris Unix, IBM AIX and BSD etc. Distributions - Fedora, Ubuntu, Debian, Linux Mint, RedHat etc.
4. It primarily uses CLI - Command Line Interface. It provides both Graphical User Interface and Command Line Interface

Ques.5. What is a Linux Loader or LILO?

Ans. Linux loader or LILO is a boot loader for Linux that loads the operating system into memory. Now a days, it is considered more of a legacy application superseded by GRUB(GRand Unified Boot loader) and GRUB2 bootloaders.

Ques.6. What is a Shell?

Ans. A shell is a program that acts as an interface between the user and operating system, allowing user to execute commands e.g. Bourne shell(sh), bash(Bourne Again Shell) etc.

Ques.7. What is a swap space? What are its advantages?

Ans. Swap space is a piece of hard-disk storage that is used when system needs more memory but the RAM is full. In such cases, the inactive memory pages are moved to swap sapce to free RAM.

Ques.8. What is a process in Linux?

Ans. A process is an instance of a program under execution. In Linux, there are two kinds of processes-

  1. Foreground processes - A foreground process when initiated by a user runs in the foreground and user has to wait for it to get completed before issuing any other command e.g. running any command on the terminal.
  2. Background processes - A background process runs on the background and the user can execute other commands also even before the background process gets executed completely. Adding '&' after any command, makes it a background process. Also, a background process can be brought to foreground using 'fg' command with jobId of the background job.

Ques.9. How can we list all the process running on a machine?

Ans. Using Top utility, we can list all the running processes. Running 'top' lists important attributes of the process like PID(process id), user/userId, parent process id, virtual memory used, physical memory used, process status, CPU utilization, process start time, command initiating the process,

Ques.10. How can we stop or terminate a running process in Linux?

Ans. Kill command is used to terminate a running process in Linux. There are two varients of killing a process-

  • Kill PId - This will generate a signal SIGTERM, specifying graceful termination of the process with process id - PId
  • Kill -9 PId - This will generate a signal SIGKILL specifying forceful termination of the process with process id - PId

Ques.11. What is the use of 'ps' command? How is it different from the top command?

Ans. Ps stands for Process Status. It gives the information about the running processes.

#To display information about the process with PId - 12
ps -p 12

#To display all process
ps -ef

It is different from top command in the sense that top displays continuous interactive usage of the processes in real time. Whereas, ps displays a single snapshot of the processes and is more likely to be used for non-interactive usage in scripts.

Ques.12. What is a daemon?

Ans. Daemons are the processes that run in background either at predefined time or in the event of a trigger. As a convention, daemon names in Linux end with the letter 'd'.

Ques.13. What is the use of man command?

Ans. Man command is used to know the usage of a command, config file or daemon using the man pages or user manual. Usage-

man ls

Output - Displays the manual page for ls command.

Ques.14. How to print the current working directory in Linux?

Ans. Pwd command is used to display the current directory (Print Working Directory)-

$ pwd

Ques.15. How to create a directory in Linux and give full permission to it?

Ans. Using mkdir, we can create a directory and then with chmod we can give permissions.

mkdir directoryName
chmod 777 directoryName

Alternatively, we can also use '-m' or mode option of 'mkdir' command and perform the operation in single command-

mkdir -m 777 directoryName

Ques.16. How to delete a non-empty directory?

Ans. On trying to delete a non-empty directory with 'rmdir directoryName' command, we will get an error - "rmdir: failed to remove 'newFolder': Directory not empty".
For removing a non-empty directory, we need to use the '-r' option of 'rm' command that recursively deletes the directory and its contents.

rm -r directoryName

Ques.17. How to change directory in Linux? How to move to parent directory, home directory and previous directory?

Ans. Using cd command, we can change directory in Linux. Usage-

cd directoryName

Move to parent directory or one level up-

cd ..

Move to user's home directory-



cd ~

Move to previous directory-

cd -

Ques.18. What is a root directory?

Ans. Linux follows a hierarchical or tree based file system. Root directory is the parent directory of the hierarchy that includes all the other directories. It is represented by a forward slash '/'.

Ques.19. What are absolute and relative paths?

Ans. Absolute path - Absolute path is the path of a file or directory from the root directory i.e. from '/'.
Relative path - Relative path is the path of a file or directory from the present working directory.

Ques.20. How to login as a different user in Linux?

Ans. 'Su' command is used to login as different user in Linux. It stands for substitute user or switch user.

#Switch to user2
su user2

#Switch to root
su root

Ques.21. What is a root account?

Ans. Root account is the account or a user that has access to each file and directory in Linux. Root account is also known as superuser. A root user can also have access to run any command including adding users, grant or revoke permissions etc.

Ques.22. What are the different file ownership in Linux?

Ans. Each file and directory in Linux can have following 3 owners-

  1. User - The user or owner permission class belongs to the user who created the file.
  2. Group - The group permission class belongs to the members of the file's group.
  3. Other - User or other permission class refers to each user who has access to the file.

Ques.23. Explain the usage of 'ls -ltr' command?

Ans. 'ls' command is used to list the directory contents. The options '-ltr' stands for-
'l' - Use long listing format
't' - Sort by modification time, newest first
'r' - Reverse order while sorting
So, 'ls -ltr' will list the content of the directory in long listing format sorted oldest first.

$ ls  imp.txt  Linux.png

$ ls -ltr
total 5072
-rw-r--r-- 1 Kuldeep 197121 5170843 Mar 30  2017
-rw-r--r-- 1 Kuldeep 197121    8695 Oct 28 14:06 Linux.png
-rw-r--r-- 1 Kuldeep 197121    6883 Dec 28 19:37 imp.txt

Ques.24. What is the significance of file extensions like .txt, .png etc in Linux?

Ans. Unlike Windows, file extensions have no significance in Linux. Linux does not rely on the file extensions instead the file type is determined by the some content in the file header.

Ques.25. Explain the usage of 'file' utility.

Ans. The file utility is used to determine the file type of a file.

$ file imp.txt
imp.txt: ASCII text, with very long lines, with CRLF line terminators

$ file Linux.png
Linux.png: PNG image data, 521 x 177, 8-bit colormap, non-interlaced