Mark As Completed Discussion

Linux Interview Questions

Introduction

Linux is an open-source, Unix-like, freely-distributable computer operating system (OS) built around the Linux Kernel. This operating system is responsible for managing the system’s hardware and resources, such as its CPU, memory, and storage, as well as managing the communication between the hardware and the software. It has been released on the 5th of October 1991 by Linus Torvalds and has been since considered quicker and more secure than Windows. Originally created for Intel x86-based personal computers, Linux is today compatible with a variety of devices, including laptops, PCs, notebooks, and smartphones.

Introduction
In this article, we’ll take a look at some of the most important Linux questions that get asked in interviews.

What are Linux's fundamental components?

Linux is composed of five distinct elements:

  • Kernel: it is the primary component of Linux and is typically in charge of all important OS tasks including process management, device management, etc.
  • System Libraries: they are specialized programs that allow application software or system utilities to access the Kernel functionality. The majority of the operating system’s features are implemented by these libraries.
  • System Utility: these utility programs are in charge of carrying out specific, individual-level duties and they provide users control over the machine.
  • Hardware: this includes physical devices such as a keyboard, display, mouse, etc.
  • Shell: it serves as an interface between the user and the kernel that isolates the user from the complexity of the kernel's functions.

The System Architecture of Linux is shown in the image below:

What are Linux's fundamental components?

What is the Linux Kernel and what are its functions?

The Linux OS's kernel is regarded as its primary component, serving as a resource manager that connects the hardware and software of the system and makes sure both are working correctly. The kernel is also known as low-level system software and is usually one of the first applications to load when a system starts up. Every Linux distribution includes an integrated kernel that may be upgraded automatically by the distribution itself.

What is the Linux Kernel and what are its functions?
Listed below are the Kernel's primary functions:

  • Manage RAM so that all open apps and active processes can function.
  • Control the amount of time the processor spends executing processes.
  • Control the use and access to the various computer peripherals.

What is BASH?

In essence, BASH (Bourne Again Shell) is a command language interpreter. It was created by Brian Fox for the GNU Operating System and it is an alternative to the Bourne Shell. While it is comparable to Bourne Shell, it has several extra capabilities like command-line editing that make it simpler and more practical to use and because of this, BASH is the default user shell on most Linux installations. Essentially, it is a non-compiled, interpreted process that can also execute in the terminal window and has the ability to read commands from shell scripts.

Explain the different kinds of permissions in Linux.

The Linux System has three types of owners: user, group, and others. These owners are granted one of the three categories of permissions indicated below:

  • Read (r): it enables the user to list the directory or open and read a file.
  • Write (w): it enables the user to access and edit the file, as well as add new files to the directory.
  • Execute (x): it enables the user to run or execute the file and search for a particular file inside of a directory.

The chmod command can be used for changing the permissions of a specific file or directory.

Build your intuition. Click the correct answer from the options.

If we have given reading permissions to the user, but writing and executing permissions to the other two types of owners (group and other), the permission readout would look like:

Click the option that best answers the question.

  • r---wx-wx
  • -rwxwx
  • -r---we-we

What is LILO?

A specific bootloader must be installed on a computer before it can be used with Linux. The Linux Loader, or LILO, is essentially the most popular Linux bootloader that loads Linux into memory and launches the operating system. It can execute a number of tasks as either a master boot program or a secondary boot program, including finding the kernel, identifying other supporting programs, loading memory, and running the kernel. However, it is important to note that there exist several other bootloaders apart from LILO, with two of them being LOADLIN (LOAD LINux) and GRUB (GRand Unified Bootloader).

What are Linux daemons?

A daemon is software that runs in the background on Linux and Unix systems without requiring any user input. The daemon's file name often ends with the letter d.

Can you explain the differences between cron and anacron?

Both cron and anacron are Linux programs used for the automatic execution of reoccurring tasks at scheduled times. A more detailed comparison of the two utilities can be seen in the table below:

Can you explain the differences between cron and anacron?

Explain the Linux Process States.

A process in Linux is a single instance of a program or command being executed. Every process will be in one of the five states depicted below for as long as it exists.

Explain the Linux Process States.

  • Created/Ready: a new process will be created and then will be ready to run during these states.
  • Running: a new process will enter the running state when it is executed. The process uses a CPU core while it is executing to carry out its logic and code.
  • Waiting: the process is waiting for user input in this state, and if it lacks resources to continue running (memory, file locks, input), it may stay in a waiting or stalled state.
  • Terminated: when a process gets into this state, it means that it has either ended on its own or has been terminated by the operating system.
  • Zombie: when the process is in the zombie state, it means that it has already ended but the process table still contains information about it.

Build your intuition. Is this statement true or false?

Anacron can be run every hour.

Press true if you believe the statement is correct, or false otherwise.

Are you sure you're getting this? Could you figure out the right sequence for this list?

Order the states as they are to be executed.

Press the below buttons in the order in which they should occur. Click on them again to un-select.

Options:

  • Ready
  • Created
  • Terminated
  • Running

What is the command for terminating a running Linux process?

The process id for each process is different. Finding the process id is the first step in terminating the process. All currently active processes and their Ids can be listed by using the ps command, and then those processes can be ended with the kill command. So, we run the ps command:

$ps

Then, assuming the process id of the process you wish to end is 1234, we must terminate it as follows:

$ kill 1234

Build your intuition. Is this statement true or false?

We can kill a Linux process even if we don’t know the process Id by using the $pkill command

Press true if you believe the statement is correct, or false otherwise.

How to find a file location in Linux?

For this, we can use the locate command. For example, if we’d like to get the location of a file named test.txt, we’d run the following command:

$ locate test.txt

One Pager Cheat Sheet

  • Linux is an open-source, Unix-like, freely-distributable computer operating system (OS) built around the Linux Kernel, responsible for managing system hardware and resources, and considered quicker and more secure than Windows, as demonstrated by the comprehensive list of Linux interview questions in this article.
  • Linux is composed of five distinct elements, such as the Kernel, System Libraries, System Utility, Hardware and Shell, which together form its System Architecture.
  • Popular Linux distributions include Ubuntu, Debian, SUSE Linux, Gentoo, and Fedora.
  • The Linux OS's kernel is a primary component, connecting the hardware and software of the system and serving as a low-level system software that loads on startup, performing functions such as managing RAM, controlling processor time, and managing peripherals.
  • BASH (Bourne Again Shell) is a command language interpreter that has additional capabilities such as command-line editing, making it the default user shell on most Linux installations and a non-compiled, interpreted process that can be executed in the terminal window.
  • Linux users have access to three types of permissions (read, write, and execute) that can be set using the chmod command.
  • The permission readout for a file with reading permissions granted to the user and writing and executing permissions granted to the group and other is r---wx-wx, indicating that the user can Read the file but not Write or Execute it, while the group and other have Write and Execute permissions.
  • The most popular Linux bootloader, LILO, is used to load Linux into memory and launch the OS, as well as finding, identifying, loading, and running the kernel.
  • A daemon is software that runs in the background on Linux and Unix systems without requiring any user input.
  • Cron and anacron are Linux programs used for scheduling automatic recurring tasks at specific times, though they function slightly differently.
  • A process in Linux is in one of five states—Created/Ready, Running, Waiting, Terminated, and Zombie—which determine its current activity and whether it has ended or needs resources.
  • Anacron is a scheduling program that runs commands at certain times, but not every hour; it is useful for non-time dependent tasks, but not designed to be a real-time scheduler.
  • Anacron automatically schedules jobs for execution and tracks times when the system was not running, typically run once a day by the cron daemon.
  • To terminate a running Linux process, use the ps command to find its process id, and then run the kill command with that Id as an argument.
  • The main advantage of pkill over kill is that it allows you to terminate a process without needing to know its exact process id, but instead by specifying its name or other attributes.
  • Boldly run the locate command to find a file location in Linux.