If you have already achieved your Linux certification and are looking forward to securing a Linux job, it pays a great deal to prepare for an interview that tests your knowledge of the ins and outs of Linux.
In this guide, we present to you some of the most commonly asked questions in Linux interviews and answers.
1. What is Linux?
Linux is a free and open-source operating system based on UNIX. It was first released in 1991 by Linus Torvalds. The goal of developing Linux was to provide a free and low-cost alternative to proprietary systems like Windows and macOS.
2. What is the Linux Kernel?
Written in C programming language, the Linux kernel is the core component of a Linux system. It is the lowest level of software that can interact with the hardware. It interfaces the OS and the underlying hardware and allows communication between the two.
The kernel performs the following major tasks:
- Manages underlying hardware devices.
- Launches and manages applications.
- Manages OS resources including RAM, CPU, and disk utilization.
3. What is GRUB?
GRUB (Grand Unified Bootloader) is a bootloader from the GNU project. It’s a program that is responsible for managing the boot process. Basically, it takes over from the BIOS at system startup and loads the kernel into the main memory. The kernel then loads the operating system and its components.
The GRUB splash screen is typically what you will see on your screen once the system starts up. It displays a simple menu that provides a couple of boot options.
4. What are the Essential Components of Linux?
A Linux system comprises the following essential components:
- Kernel – This is the core part of the Linx system that manages underlying hardware components and applications at the OS level.
- Shell – This is an interpreter that provides a command-line interface that accepts commands issued through the keyboard and passes them to the OS for execution.
- GUI – This is an acronym for Graphical User Interface. It comprises graphical components that users leverage to interact with the system. These include the desktop, windows, icons, buttons, taskbars, and pop-ups.
- Application programs – These are software applications installed on a Linux system that perform specific tasks. For example Firefox web browser, VLC media player, LibreOffice suite, and many more.
5. What are Shells Used in Linux?
Commonly used shells In Linux include:
- bash [Bourne Again Shell] – This is the default shell on a majority of Linux systems.
- zsh [Z Shell] – This is the default shell in Kali Linux and macOS. It is built on top of bash and packs with additional features such as spelling correction, plugin support, better customization, etc.
- ksh [Korn Shell] – This is a high-level programming language shell.
- csh [C Shell] – Its syntax borrows heavily from the C programming language. Highly useful for anyone with C programming knowledge.
6. What is Swap Space in Linux?
Swap space refers to space on the hard drive that is an extension of the RAM or physical memory. It is used by the system when the RAM capacity is almost depleted and can no longer support running applications. Swap space stores additional programs which can no longer be processed by the RAM.
7. How to Check Linux Memory Utilization?
The following are some of the most used Linux commands you can use to check your system’s memory utilization.
- free – Display the amount of free and used memory in the system.
- top – Display running Linux processes and utilization.
- htop – An interactive system monitor, process viewer, and process manager.
- vmstat – Display virtual memory statistics.
To check your Linux system memory performance and utilization, run:
$ free -m $ top $ htop $ vmstat
8. How to Check Linux Disk Space Utilization?
Disk space usage can be checked using the df and du commands.
df Command – Show Linux File System Disk Usage
The df command (short for disk free) is used to display the total and available disk space for the filesystems on your system. It is often used with the
-Th options for displaying the output in a human-readable format.
$ df -Th
du Command – Show Disk Usage of Files and Directories
The du command (short for disk usage) displays the file space usage in a directory. It tracks space occupied by files and directories. Like the df command, du is used with the
-h option to display output in a human-readable format.
$ du -h
9. What are an Inode and PID?
An inode is a file structure that stores metadata for files in Linux. The metadata includes file size, permissions needed to access the file, user and group ID, creation timestamp, and the path to the file.
An inode number is a unique number or integer given to each file on a Linux system.
$ ls -li ravi.txt 1594567 -rwxrwxr-x 1 tecmint tecmint 0 Oct 28 10:58 ravi.txt
1594567 is the inode number and the
-i flag shows the inode of the ravi.txt file.
A PID (Process ID) is a unique ID given to each running process on a Linux system. We can use the pidof command to find the process ID of any running program.
$ pidof firefox 40982
10. What are Daemons?
Daemons are service processes that run in the background without any user interaction. They provide the functionality to other processes and handle periodic requests and forward them to appropriate applications for execution.
11. What are Process States in Linux?
In Linux, a process is an instance of a running program or service. There are four process states. At any given time, a process will be in any of the following states:
- Ready: The process has already been created and is ready to run.
- Running: The process is alive or being executed.
- Stopped: The process finished running and was terminated by the operating system.
- Wait: The process is waiting for some user input.
- Zombie: The process has been terminated, but the information still exists in the process table.
To check the Linux process state use the ps command as shown.
$ ps a
The STAT column shows the running state of the process.
12. What is GUI?
GUI is an acronym for Graphical User Interface. These are the graphical elements of a Linux operating system which include windows, icons, menus, buttons, taskbars, and much more.
The GUI makes it easier to interact with the system and is mostly preferred by beginners or novices who are not adept at working on the CLI.
13. What is CLI?
CLI is an acronym for Command Line Interface. This is an interface that allows users to type commands on a shell provided by the terminal. The CLI is mostly used by experienced Linux users or system administrators and engineers.
The CLI is the preferred mode of administering the system since it consumes fewer system resources, unlike the GUI which has a high resource overhead.
14. What is the Root Account?
This is the most privileged account on the Linux system. It allows you full control of the Linux system. You can do virtually anything you want including upgrading the system, installing and uninstalling software packages, creating and removing users, configuring services, and much more.
In most Linux distributions, you will be required to create a root account during installation.
15. What is Open Source Software?
The characteristic of software being open source implies that you view its source code, modify it, and redistribute it to other users without license restrictions. Other users would then be in a position to make further changes including debugging and rectifying errors in the source code.
In effect, open-source software becomes widely used and hence benefits everyone.
16. What are the Linux Directory Commands?
The following are the main Linux directory commands:
- pwd – The command displays the present working directory or your current directory path.
- ls – This command lists the contents of a directory.
- cd – This lets you switch from one directory to another.
- mkdir – The command creates a new empty directory.
- rmdir – The command deletes or removes an empty directory.
- rm – Removes one or multiple files. Used with -R option to remove a non-empty directory.
17. What is the Redirection Operator?
Redirection is the process of sending the output of the first command to another file. In addition, it’s also used to direct an output as an input to another process.
In Linux, redirection is achieved using either the
">" (greater-than symbol) or the
"|" (pipe) operator which sends the standard output of one command to another command as standard input.
18. What are the Different Vim Modes?
The vim editor provides the following main modes:
- Normal mode / Command mode – This is the default mode when you open a new file or an existing one. In this mode, you can run commands such as undo, redo, and paste.
- Insert mode – This mode allows you to type in the text.
- Visual mode – This mode lets you select text so that you can perform other tasks with it such as cop, cut or paste.
19. What is an Alias?
As the name suggests, aliases are like custom shortcuts used to represent a command (or set of commands) executed with or without custom options.
20. How to List All Processes Running on a Linux?
To list all running processes on a Linux system, run the command:
# ps aux
The command lists all the currently running processes, including their PID (Process ID) numbers.
21. What is a Soft Link?
A soft link, also known as a symbolic link, is similar to a file shortcut on the Windows operating system. It contains the path of the file and not its contents.
A soft link can be linked to either a file or a directory. If the original file is removed, the soft link breaks and is referred to as the hanging link. However, the removal of the soft itself doesn’t affect anything.
In addition, soft links can link across file systems.
22. What is a Hard Link?
A hard link is a file shortcut that links the actual contents of a file, unlike a soft link which only contains the file path. It’s the same size as the original file and shares the same inode number as the original file.
When the origins file is updated, the contents of the hard link also get updated. In addition, the hard link remains unaffected even if the original file is removed.
The drawback of a hard link is that it cannot be created across different file systems.
23. What are Hidden Files in Linux?
Hidden files are files that are preceded by a dot or period. They mostly contain configuration files that hold important data or settings. To view hidden files, use the ls command with the
$ ls -la
24. What are the Different Types of Permissions in Linux?
There are 3 distinct file permissions in Linux:
- Read (r) – Allows users to read files or list a directory.
- Write (w) – Allows the user to modify or edit files.
- Execute (x) – Allows users to run the file.
25. How do Change the Permissions of a File or Directory?
The chmod command is the command that modifies the permissions of a file or directory.
It follows the syntax shown.
# chmod [OPTIONS] [permissions] file
For example. To assign octal permissions 755 (all permissions to the owner and read and write permissions only for the group members and everyone else) to a file called file1.txt, run the command.
# chmod 755 file1.txt
26. What is the Grep Command?
Grep is a command line tool for searching and matching text files or lines in a text file. It takes options and parameters which are used to manipulate or enhance the search output.
It takes the following syntax:
$ grep [options] pattern [files]
The following command counts the number of occurrences of the string ‘Unix‘ in file1.txt.
$ grep -c "Unix" file1.txt
27. How to Terminate a Running Process in Linux?
To terminate or kill a process, use the kill command followed by the PID of the process.
The ps command will help you to identify the PID of a process.
$ kill PID
To terminate an unresponsive process, pass the
-9 option shown
$ kill -9 PID
To kill a process by name, use the killall command followed by the process name. For example, to terminate the Firefox process, run the command:
$ killall firefox
28. How to Run Multiple Commands in a Single Command?
To run multiple commands one after the other in a single command, you can use either the semi-colon
';', double ampersand
- X Y – This runs commands X and Y regardless of the success of X.
- X && Y – This runs Y if and only if X runs successfully.
- X || Y – This runs Y if and only if X fails.
29. Check How Long the Linux System Has Been Running?
To verify the uptime or how long a system has been running, simply run the uptime command as shown.
$ uptime 12:09:11 up 2:49, 2 users, load average: 0.62, 0.97, 0.88
30. How to Check Linux System Information?
To check basic system information such as kernel name and version, hostname, and operating system, run the uname command using the
-a option as shown.
$ uname -a Linux tecmint 5.15.0-53-generic #59~20.04.1-Ubuntu SMP Thu Oct 20 15:10:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Admittedly, this is by no means a comprehensive list of all the interview questions that you are bound to face in the interview room. However, you are more likely to face these interview questions to test your basic understanding of the Linux system. All the best as you prepare for your interview.
Did we miss any important Linux interview questions? What do you think about these questions? If you have any interview questions do share them in the comments below.