December 1, 2023

Part-2: Basic 10 Linux Interview Questions and Answers

In this article, we’ve included another set of 10 basic Linux Interview Questions and detailed answers that will help candidates prepare for the Linux interview.

These Linux interview questions and answers will be useful for both freshers and experienced users.

Q.1) What is Process in Linux?

A process is a running instance of a program. The init or systemd is always the first process in the system and the ancestor of all other processes.

You can list all active/running processes using the ‘ps’ command as shown below.

ps -ef

root 1 0 0 08:22 ? 00:00:16 /usr/lib/systemd/systemd --switched-root --system --deserialize 29
root 2 0 0 08:22 ? 00:00:00 [kthreadd]
root 3 2 0 08:22 ? 00:00:00 [rcu_gp]
root 4 2 0 08:22 ? 00:00:00 [rcu_par_gp]
root 6 2 0 08:22 ? 00:00:00 [kworker/0:0H-kblockd]
root 9 2 0 08:22 ? 00:00:00 [mm_percpu_wq]
root 10 2 0 08:22 ? 00:00:01 [ksoftirqd/0]
root 11 2 0 08:22 ? 00:00:15 [rcu_sched]

Q.2) What is Process ID (PID) in Linux?

PID refers to a process ID, commonly used by most operating system kernel, such as Linux, Unix, MacOS, and Windows.

This is a unique ID that is automatically assigned to each process when it is created.

The default maximum value of PIDs is 32,768 on 32-bit systems, but can be set to any value up to 2^22 (approximately 4 million) on 64-bit systems.

You can find a specific process ID of a running program using the ‘pidof’ command. For instance, to check nginx process ID, run:

pidof nginx

29731 489 488 487 486 485

Q.3) What is Parent Process (PPID) in Linux?

A parent process is a process that has created one or more child processes. Each child process is given a Parent Process ID (PPID), and the parent process kills the child when it completes the process.

You can use the ‘pstree’ command to identify the parent process ID of the running program, which separates the parent process from the child processes using the branch.

pstree -p | grep -w "sshd"

|            |-sshd(10625)
|            `-sshd(10676)---sshd(10677)

Q.4) What is Daemon in Linux?

The daemon is a program on a Unix-like operating system that runs in the background and has no interaction with the user.

For example, the daemon that handles the Apache web server functionality is httpd.

Q.5) What’s Service in Linux?

A service is a process or program that runs in the background and does not interact with the user.

The services are also commonly known as daemons, and it supports a variety of options such as Start, Stop, Restart, Enable, Disable and Mask.

For instance, sshd is the daemon that handles the openssh server.

Q.6) How to check list of enabled service on boot in Linux?

Run one of the following commands based on your system manager to list the services that were enabled on boot in Linux.

For System V (SysV) init system, run:

service --status-all

abrt-ccpp hook is installed
abrtd (pid 2131) is running…
abrt-dump-oops is stopped
acpid (pid 1958) is running…
atd (pid 2164) is running…
auditd (pid 1731) is running…

For systemd system, run:

systemctl list-unit-files --state=enabled

Q.7) What’s swap space in Linux?

Swap space on Linux is used when the amount of physical memory (RAM) is filled. When the physical RAM is full, the inactive pages in the memory are moved to the swap space.

This enables the computer to run the application continuously, but is not considered a replacement for high RAM.

Swap space is located on hard drives, so it does not process a request like RAM.

How do I check the size of swap space on my system?

You can identify the current swap space on Linux using the ‘free’ command.

free -m
              total        used        free      shared  buff/cache   available
Mem:          15831        4264        3316        2587        8250        8695
Swap:          2048           0        2048

What is the recommended swap size on Linux?

Generally, the recommended swap size is twice the amount of RAM, but this is no longer required to modern computers. However, you may need to create a swap space based on the application requirement.

For example: Oracle Data Base server, SAP application, etc,.

How to format swap partition on Linux?

The mkswap command is used to format a partition for swap space.

sudo mkswap /dev/device

How to activate swap partition?

To activate new swap partition, run:

sudo swapon -va /dev/device

How to remove swap space partition?

Swap space can be removed or disabled using the following command.

sudo swapoff -v /dev/device

Q.8) What is Linux /tmp partition?

The “/tmp” directory is a directory used to hold temporary files (or session files) when the application is running.

This is particularly useful in many user environments, where unprivileged users will have access to read/write data to /tmp.

It is linked to a special file system called tmpfs. This is a virtual file system and the operating system automatically loads the /tmp mount point when the system boots.

Temporary files are automatically deleted by the application when they are finished.

The /tmp directory is cleaned by default during system startup or reboot.

Q.9) What is sysfs filesystem in Linux?

sysfs filesystem is a pseudo-file system which provides an interface to the kernel data structures, which changes dynamically whenever a device is inserted or removed.

Files under sysfs provides an information about devices, kernel modules, filesystems and other kernel components.

sysfs file system is commonly mounted at “/sys”. Typically, it is mounted automatically by the system.

ls -lh /sys

total 0
drwxr-xr-x   2 root root 0 Sep  2 20:14 block
drwxr-xr-x  42 root root 0 Sep  2 20:14 bus
drwxr-xr-x  70 root root 0 Sep  2 20:14 class
drwxr-xr-x   4 root root 0 Sep  2 20:14 dev
drwxr-xr-x  27 root root 0 Sep  2 20:14 devices
drwxr-xr-x   5 root root 0 Sep  2 20:14 firmware
drwxr-xr-x   7 root root 0 Sep  2 20:14 fs
drwxr-xr-x   2 root root 0 Sep  2 20:14 hypervisor
drwxr-xr-x  14 root root 0 Sep  2 20:14 kernel
drwxr-xr-x 248 root root 0 Sep  2 20:14 module
drwxr-xr-x   2 root root 0 Sep  2 20:14 power

Q.10) What is procfs filesystem in Linux?

The proc filesystem (procfs) is a special filesystem in Unix-like operating systems that presents information about processes and other system information.

It’s sometimes referred to as a process information pseudo-file system. It doesn’t contain ‘real’ files but run time system information (e.g. system memory, devices mounted, hardware configuration, etc).

ls -lh /proc

total 0
-r--r--r-- 1 root root 0 Aug 22 08:18 cgroups
-r--r--r-- 1 root root 0 Aug 22 08:18 cmdline
-r--r--r-- 1 root root 55K Aug 22 20:45 config.gz
-r--r--r-- 1 root root 0 Aug 22 02:49 consoles
-r--r--r-- 1 root root 0 Aug 22 08:18 cpuinfo
-r--r--r-- 1 root root 0 Aug 22 20:45 crypto
-r--r--r-- 1 root root 0 Aug 22 08:18 devices
-r--r--r-- 1 root root 0 Aug 22 20:45 diskstats


In this guide, we’ve included the most frequently asked another set of 10 basic Linux Interview Questions and detailed answers for your reference purpose and we hope it will be very useful.

If you have any questions or feedback, feel free to comment below.

Leave a Reply

%d bloggers like this: