Introduction To Linux Interview Questions And Answers
Below is the list of 2019 Linux Interview Questions and Answers, which can be asked during an interview for fresher and experience. These top interview questions are divided into two parts:
Part 1 – Linux Interview Questions (Basic)
This first part covers basic Linux interview questions and answers
1. What are the different layers of Linux?
Below are the different layers of Linux as following:
- Hardware’s – 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 with hides complexities of the underlying hardware and provides a high-level abstraction to upper layers. There are different types of kernels like a microkernel, 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 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 it for execution.
- Utility Programs(Utilities) – These programs or software running on a top layer of OS help user for day to day generic activities like schedule a cron job or a specific task like create text documents.
2. Explain briefly about three popular Linux shells?
- Bash Shell – Default shell in many Linux/Unix distribution. 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 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.More than 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.
Let us move to the next Linux Interview Questions.
3. What is the command used to get a guide on how to use a command?
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 –
The name of the command or function and simple explanation of it.
For commands how to run it and parameters it takes. For functions, a list of the parameters it takes and which header file contains its definition.
4.5 (2,153 ratings)
A detailed description of command or function we are searching for.
Some examples of usages.Most helpful section
This section will have a list of related commands or functions.
4. How to get a list of currently running processes and resource utilization in Linux?
This is 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 used to start a process.
- The popular option used with top command –
- top -u -> Process by a user.
- top – i -> exclude idle tasks
- top -p -> Show a particular process
5. What is a pipeline operator in Linux?
Pipeline operator in Linux is used to redirect the output of one program or command to another program/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 Linux Interview Questions.
6. Explain file permission in Linux. How to change it?
Permissions are established for all files and directories. Permissions specify who can access a file or directory, and the types of access. All files and directories are owned by a user.
- 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 different approaches. The parameter file(s) is one or more files (or directories). One approach to specify permissions is to describe the changes to be applied as a combination of u, g, o along with r, w, x. To add permission, use + and to remove permission, use –.
7. What is the process in a Linux context?
A process is a running program. Processes can be started from the GUI or the command line. Processes can also start other processes. Whenever a process runs, Linux keeps track of it through a process ID (PID). After booting, the first process is an initialization process called init. It is given a PID of 1. From that point on, each new process gets the next available PID.
A process can only be created by another process. 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. The spawning of a process can be accomplished in one of several ways. Each requires a system call (function call) to the Linux kernel. These function calls are fork(), vfork(), clone(), wait(), and exec().
Let us move to the next Linux Interview Questions.
8. What are Regular Expressions(regex)? What is the meaning of *,+,? In regular expression?
A regular expression (regex) is a string that expresses a pattern used to match against other strings. The pattern will either match some portion of another string or not. There is a list of predefined metacharacters used in a regex.
- * 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
9. What is a sed command?
This is the popular Linux interview questions asked in an interview. 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 which represents a pattern of what you want to replace. The generic form of a sed command is sed ‘s/pattern/replacement/’ filename.
10. What is the difference between Hard Link and Soft Link?
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. A file will only be deleted from disk when the last link to its inode is removed.
This has been a guide to List Of Linux Interview Questions and Answers so that the candidate can crackdown these Linux Interview Questions easily. You may also look at the following articles to learn more –