Linux Interview Questions And Answers

10 Highly Important Linux Interview Questions And Answers

Are you searching for Linux interview questions and answers? The team at GoApti has prepared a list of 10 questions to assist you in your preparation.

Click here to learn more about some frequently asked non-technical interview questions.

1. What are the different layers in a Linux operating system?

The layers present in a Linux operating system are:

  • Hardware: The innermost layer consists of physical devices like RAM, CPU, etc. There may be driver software to communicate with devices in some OS.
  • Kernel: Kernel is the heart of an OS which hides the complexities of the underlying hardware and provides a high-level abstraction to upper layers. There are different types of kernels: microkernel, monolithic kernel, etc. The Linux kernel is of monolithic type.
  • Shell: The shell is a program that runs on top of the kernel. It acts as the primary method of interaction between the user and the kernel. In other words, it is a program that can run other programs. The shell accepts commands and passes it for execution. Nowadays, GUI has replaced the shell to a large extent.
  • Utility Programs (utilities): These are programs or software that run on top of the operating system. They help users for day-to-day generic activities like scheduling a cron job or for specific tasks like creating text documents.

2. What are the three popular Linux shells?

  • Bash Shell: It is the default shell in many Linux/Unix distributions. Bash has features like:
    • Edit command history.
    • Shell functions and gives aliases to it.
    • Unlimited command history.
    • Array with unlimited size.
  • Tcsh/Csh Shell (also known as C shell): Tcsh is an enhanced C shell. It has the following features:
    • More of C like syntax.
    • Auto-completion of words and filename is programmable.
    • Spell check.
    • Job control.
  • K Shell: The K shell is known as Korn shell or Ksh. Much more than an interactive shell, the K shell is a complete, powerful, high-level programming language. Some features of the K shell are:
    • Options and variables that give you more ways to customize your environment.
    • Advanced security features.
    • Advanced regular expressions and well-known utilities like grep and awk.

3. What are Manual Pages?

Manual pages hold an explanation of every available command. The manual page for a specific command contains the entire information about that command.

How do you invoke the manual pages command? “Man ls” is one way of calling the command. This command shows a detailed explanation of the “ls” command. Manual pages are categorized into different categories: user commands, system calls, library functions, etc.

The general layout of a manual page is:

  • NAME: The name of the command or function and a brief explanation about it.
  • SYNOPSIS: Tells how to run the command and the parameters it takes. For functions, a list of the parameters it takes and the name of the header file which contains its definition.
  • DESCRIPTION: A detailed description of the command or function we are searching for.
  • EXAMPLES: Some examples of the command’s usages.
  • SEE ALSO: This section contains a list of related commands or functions.

4. How do you retrieve the list of currently running processes and resource utilization in Linux?

This is one of the basic Linux interview questions. Below is the process and resource utilization in Linux are as follows:

The “top” command is used for this requirement. It gives information about each process running on the machine like:

  • Process ID (PID).
  • Owner of the process (USER).
  • The priority of the process (PR).
  • Percentage of CPU (%CPU).
  • Percentage of memory.
  • Total CPU time spent on the process.
  • Command used to start a process.

Commonly used parameters employed with the top command are:

  • top -u -> Process by a user.
  • top -i -> Exclude idle tasks.
  • top -p -> Shows a particular process.

5. What is the pipeline operator in Linux?

The pipeline operator in Linux is used to redirect the output of one program or command to another program/command for further processing. It is usually termed as redirection. Vertical bars, ’|’ (“pipes” in common Unix verbiage), are used for this. For example, the ls -l | grep key, will redirect the output of the ls -l command to the grep key command.

1000+ Question on Linux Operating System

6. What is file permission in Linux?

Permissions are established for all files and directories. Permissions specify who can access a file or directory along with the type of access. All files and directories are owned by a user. Permissions are controlled at three levels:

  • Owner level (user, or ‘u’).
  • Group level (‘g’).
  • Other users (‘o’).

There are three levels of access:

  • Read: The file can only be viewed or copied.
  • Write: The file can be overwritten.
  • Execute: The file can be executed.

To change the permission, chmod < file(s)> is used. 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, and o along with r, w, and x. To add permission, use + and to remove permission, use .

7. What is a process in Linux?

A process is a running program. Processes can be started from the GUI or from 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 several ways. Each requires a system call (function call) to the Linux kernel. These function calls are fork(), vfork(), clone(), wait(), and exec().

Read more about Linux Operating System at Wikipedia.

8. What are regular expressions (regex)?

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 won’t match at all. There is a list of predefined metacharacters used in a regex:

  • *  (asterisk) is used to match the preceding character if it appears 0 or more times.
  • + (plus) is used to match the preceding character if it appears 1 or more times.
  • ?  (question mark) is used to match the preceding character if it appears 0 or 1 time.

9. What is the sed command used for?

Commonly asked Linux interview questions and answers are incomplete without sed. 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 that represents a pattern of what you want to replace. The generic form of the sed command is sed ‘s/pattern/replacement/’ filename.

10. What is the difference between a hard link and a soft link?

A soft link (also known as a symbolic link) points to another file by name. Since it contains only a name, that name does not actually have to exist or exist on a different file system. If you replace the file or change the file content without changing its name, the soft link still contains the same name and points to that file. A hard link points to the file by inode number. The 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.

Are you aware of frequently asked Linux interview questions? Have you appeared for a Linux interview before? Do you have certifications in Linux? We’d love to know in the comments.

Leave a Comment