Updated June 15, 2023
Introduction to Linux Interview Questions and Answers
Below is the list of 2023 Linux Interview Questions and Answers, which can be asked during an interview for a fresher experience.
Part 1 – Linux Interview Questions (Basic)
This first part covers basic interview questions and answers:
Q1. What are the different layers of Linux?
Answer:
Below are the different layers of Linux as following:
- Hardware – Innermost layer consists of physical devices like RAM, CPU, etc. There might be driver software to communicate with devices in some OS.
- Kernel – Kernel is a heart of an OS that hides the complexities of the underlying hardware and provides a high-level abstraction to upper layers. There are different types of kernels a microkernels, Monolithic Kernel, etc. Linux kernel is a Monolithic type.
- Shell – Shell is a program running on top of the Kernel, which acts as a primary method of interaction between the user and kernel. Simply saying it is a program that can run other programs. Nowadays, GUI replaces shell to a large extent. Shell accepts commands and passes them for execution.
- Utility Programs(Utilities) – These programs or software running on a top layer of OS help users with day-to-day generic activities like scheduling a cron job or a specific task like creating text documents.
Q2. Explain briefly about three popular Linux shells.
Answer:
- Bash Shell – Default shell in many Linux/Unix distributions.
It has features like:
-
- Edit command history.
- Shell functions and gives aliases to it.
- Unlimited command history.
- Array with unlimited size with index.
- Tcsh/Csh Shell (Normally called C shell) – Tcsh is an enhanced C shell.
- More of C like syntax.
- Auto-completion of word and filename is programmable.
- Spell check.
- Job control.
- K Shell – It is called Korn Shell or Ksh. Unlike an interactive Shell, K shell is a complete, powerful, high-level programming language.
It has features like:
-
- Options and variables that give you more ways to customize your environment.
- Advanced security features
- Advanced regular expressions- well-known utilities like grep and awk.
Q3. What is the command used to get a guide on how to use a command?
Answer:
Manual pages are where an explanation of every command has stored. Manual pages for a specific command will have all information about that command, and it can be called as ‘man <command> eg: ‘man ls’.Manual pages are categorized into different sets of user commands, system calls, library functions..etc..
A general layout of a manual page is as follows:
- NAME: The name of the command or function and a simple explanation of it.
- SYNOPSIS: For commands, how to run it, and the parameters it takes. For functions, a list of the parameters it takes and which header file contains its definition.
- DESCRIPTION: A detailed description of the command or function we are searching for.
- EXAMPLES: Some examples of usages.Most helpful section
- SEE ALSO: This section will list related commands or functions.
Q4. How to get a list of currently running processes and resource utilization in Linux?
Answer:
These are the basic Linux Interview Questions asked in an interview.
Below is the process and resource utilization in Linux are as follows:
- The top is the command used for this. This will give all information about each process running on a machine like:
- 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 is used to Start a Process
- The popular option is used with the top command.
- top -u -> Process by a user.
- top – i -> Exclude idle tasks.
- top -p -> Show a particular process.
Q5. What is a pipeline operator in Linux?
Answer:
The pipeline operator in Linux is used to redirect the output of one program or command to another program or command for further processing. Usually termed as redirection. Vertical bars,’|’ (“pipes” in common Unix verbiage), are used for this. For example, ls -l | grep key will redirect the output of ls -l command to grep key command.
Part 2 – Linux Interview Questions (Advanced)
Let us now have a look at the advanced Interview Questions:
Q6. Explain file permission in Linux. How to change it?
Answer:
Permissions specify who can access a file or directory and the types of access.
A user owns all files and directories.
- Permissions are controlled at three levels.
- Owner (called a user, or ‘u’)
- Group (‘g’)
- The rest users(called other, or ‘o’)
- Level of access
- Read – Filet can be viewed or copied
- Write – File can be overwritten (e.g., using save as)
- Execute – File can be executed
To change permission – chmod <permissions> < file(s)> is used. Here permissions can be specified in different approaches. The parameter file(s) is one or more files (or directories). To add permission, use +, and to remove permission, use –.
Q7. What is the process in a Linux context?
Answer:
A process is a running program. Processes can also start other processes. Whenever a process runs, Linux keeps track of it through a process ID (PID). From that point on, each new process gets the next available PID.
We refer to the creating process as the parent and the created process as the child. The parent process spawns one or more child processes. system call (function call) to the Linux kernel. These function calls are fork(), vfork(), clone(), wait(), and exec().
Q8. What are Regular Expressions(regex)? What is the meaning of *,+,? In regular expression?
Answer:
The pattern will either match some portion of another string or not.
- * Used to match the preceding character if it appears 0 or more times.
- +Used to match the preceding character if it appears 1 or more times.
- ? Used to match the preceding character if it appears 0 or 1 times.
Q9. What is a sed command?
Answer:
Sed is a stream editor. A stream editor is a program that takes a stream of text and modifies it. With sed, you specify a regular expression representing a pattern of what you want to replace. The generic form of a sed command follows the pattern sed ‘s/pattern/replacement/’ filename..
Q10. What is the difference between Hard Link and a Soft Link?
Answer:
A soft link(Symbolic Link) points to another file by name. As it just contains a name, that name does not actually have to exist or exist on a different file system. If you replace the file or change file content without changing a name, then the link still contains the same name and points to that file. A hard link points to the file by inode number. A file should actually exist in the same file system.
Recommended Articles
We hope that this EDUCBA information on “Linux Interview Questions” was beneficial to you. You can view EDUCBA’s recommended articles for more information.