Prepare for Linux interview with our comprehensive list of over 50 interview questions. These interview questions are specifically designed for freshers and professional new to linux OS.
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-
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-
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 etc.
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-
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.
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-
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)-
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.
Alternatively, we can also use '-m' or mode option of 'mkdir' command and perform the operation in single command-
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.
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-
Move to parent directory or one level up-
Move to user's home directory-
Move to previous directory-
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.
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-
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.
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.