We have prepared Linux Interview Questions and Answers for the learners to have a clear idea about the technical rounds of top companies.
- What are the important features of Linux OS?
Linux has the following features for its users
- Free and open-source
- Robust and adaptable
- More secure with authentication
- Multiprogramming system
- Application support
- Customized keywords for languages
- Graphical User Interface
- Explain the fundamental components of Linux
Linux has five basic components or elements as follows:
System Library: They are special programs and functions that help on which application programs or system utilities to access kernel features without any coding requirement. It is used to implement the functionalities of the operating systems.
System Utility: They are utility programs responsible for performing individual and specialized tasks. They are more liable and enable users to manage the computer.
Hardware: It is physical elements that include a mouse, display, keyboard, CPU, etc.
Shell: It is a platform in which we can run our commands, programs, and shell scripts. It is an interface between user and kernel that hides all complications of functions of the kernel from the user and it is used to execute commands.
- Explain kernel and its functions
Its primary goal is to manage hardware resources for users and it is used to provide an interface for user-level interaction.
- Memory management
- Process management
- Device management
- Storage management
- Manage access
- Define BASH
BASH stands for Bourne Again Shell which is a command language interpreter. Brain Fox for GNU OS has written BASH and it can be used in Bourne Shell.
It includes additional features like command-line editing to make it easier and more convenient to use.
It is the default user shell on Linux installations and it is an interpreted and non-compiled process that can also run in the terminal window. BASH is also capable of reading commands from shell scripts.
- What are the two modes available in Linux?
Linux has two types of modes as Command-line and Graphical User Interface (GUI).
- Define LILO
It is also known as a boot manager to facilitate a dual boot of a computer and it can function as either a master boot program or secondary boot program and performs various functions such as locating kernel, loading memory, identifying supporting programs, and starting the kernel.
- Define the Process States in Linux
- New/Ready: A new process is created and ready to run in this state
- Running: The processing will be executed in this state
- Blocked / Wait: The process is waiting for input from the user in this state and if there are no resources to run such as file locks, memory, input, etc then it will remain in a waiting state or blocked state.
- Terminated / Completed: The process has completed the execution or terminated by the OS in this state.
- Zombie: The process will be terminated in this state but information regarding the process will be available in the process table.
- Define Swap Space
Swap space is a space on a hard disk used when the amount of physical memory or RAM becomes full.
It will be considered a substitute for physical memory and its main function is to substitute disk space for RAM when real RAM doesn’t have enough space to hold all programs that are running then more space will be required.
As a whole, Swap Space is used as an extension of RAM in Linux.
- Explain Shell and its types
It accepts human-readable commands as input and translates them into kernel understandable language.
There are various types of Shells used on typical Linux systems such as CSH (C Shell), KSH (Korn Shell), BASH (Bourne Again Shell), TCSH, ZSH, and Bourne Shell.
- List various types of modes used in the VI editor
VI Editor stands for Visual Editor which is a default text editor that usually comes with most of the Linux OS. There are three types of modes used in the VI editor as given below
- Command Mode/Regular Mode: It is the default mode for the VI editors and it is used to type commands that perform specific vi functions. To enter this mode from another mode (Insert Mode), one should press [esc]. It allows users to view the content.
- Insertion Mode/Edit Mode: It allows users to do text editing or type text into a file. We must press [esc] to enter this mode from command mode or another mode. It allows users to delete or insert text or content.
- Ex Mode/Replacement Mode: It is used to store the files and execute the commands and it executes files with various parameters. One should press [:] to enter this mode. It allows users to overwrite text or content.
- What is the maximum length for a filename in Linux?
The maximum length for a filename is 255 bytes in Linux OS.
- Define Virtual Desktop
Virtual Desktop is a feature in Linux that enables users to utilize the desktop beyond the physical limits of the screen.
It creates a virtual screen to expand the limitation of the normal screen. There are two different ways can be implemented Virtual Desktop
Switching Desktop: Users can create discrete virtual desktops to execute programs in switching desktops.
Here, every virtual desktop will act as an individual desktop and the programs running on each of these desktops is available only to the users who are using the specific desktop.
Oversized Desktop: It doesn’t offer a discrete virtual desktop but it enables the user to pan and scroll around the desktop that it was bigger than the physical screen.
- Explain Daemons
A daemon is a computer program that runs as a background process to offer functions that might not be available in the base Operating System.
Daemons are usually used to execute services in the background without directly being in control of interactive users.
The reason for daemons is to manage periodic requests and forward the requests to proper programs for execution.
- What are the various modes of vi editor?
There are three various modes of vi editor
- Regular/Command Mode that allows users to view the content
- Insertion/Edit Mode that allows users to delete or insert content
- Replacement Mode that allows users to overwrite content
- Define permission in Linux
There are three kinds of permission in Linux such as read, write, and execute.
Read allows a user to open and read the file, write allows users to open and edit the file, and execute allows a user to execute the file.
The user can change the permission of a file or a directory using the chmodCommand.
Symbolic mode and absolute mode are using the chmod command.
The general syntax to change permission in Symbolic mode is as follows
$ chmod <target>(+/-/=) <permission><filename>
Where, <permission> can be r: read; w:write; x:execute.
<target> can be u:user; g:group; o:other; a:all
‘+’ is used to add permission, ‘-‘ is used to remove permission, and ‘=’ is used to set the permission
Setting permission for the user to read, write, and execute. Setting permission for the group to read and execute. Setting permission for others to only read.
$ chmod u = rwx, g = rx, o =r filename
The absolute mode follows octal representation and following is the syntax for absolute mode
$ chmod <permission> filename
The leftmost digit is for the user, the middle digit is for the group, and the rightmost digit is for all
The following table explains the meaning of digits that are used along with their effects.
|3||Execute and write permission: 1 (execute) + 2 (write) = 3||-wx|
|5||Read and execute permission: 4 (read) + 1 (execute) = 5||r-x|
|6||Read and write permission: 4(read) + 2 (write) = 6||rw-|
|7||All permissions: 4 (read) + 2 (write)+ 1 (execute) = 7||rwx|
Setting permission for a user with reading, write, and execute, group members to read and execute, and others to only read. Following is the command
$ chmod 754 filename
- Define inode and process id
The process id is the unique id given to each process while the inode is the unique name given by the operating system to each file.
- List the various Directory Commands of Linux
There are five major directory commands in Linux
- pwd is the command used to display the path of the present working directory. Syntax: $ pwd
- ls command is used to list all the files and directories in the present working directory. Syntax: $ls
- cd is used to change the present working directory. Syntax: $ cd <path to new directory>
- mkdir is used to create a new directory. Syntax: $mkdir<name (and path if required) of new directory>.
- rmdir is used to delete a directory. Syntax: $ rmdir <name (and path if required) of new directory>.
- Define LVM
LVM stands for Logical Volume Management and is a tool to provide logical volume management for the Linux Kernel.
It is used to make physical storage device management easier and it consists of allocating disks, mirroring, striping, and resizing logical volumes.
The main advantages of LVM are flexibility, increased abstraction, and control. It allows for flexible disk management and it is required to resize the size of the file system online.
In Linux, the size of the LVM will be extended using the “lvextend” command and it can be reduced using “lvreduce” commands respectively.
- Explain the “/proc” file system
Proc file system is a virtual or pseudo-file system that offers an interface to the kernel data structure.
It includes useful information about processes that are running currently.
It will be used to change kernel parameters at runtime or during execution. It controls the information center for the kernel.
All files under this directory will be named virtual files.
- Differentiate cron and anacron
Cron is a program in Linux used to execute tasks at a scheduled time and it works effectively on machines that run continuously.
Anacron is also a program in Linux used to execute tasks at particular intervals and it works effectively on machines that are powered off during a day or week.
|Cron is a Daemon||Anacron is not a daemon|
|Scheduled by any normal user||Scheduled only by super users|
|Ideal for servers||Ideal for desktops and laptops|
|Expect the system to run 24 * 7||Don’t expect the system to run 24 * 7|
|Minimum granularity is in minutes||Minimum granularity is only in days|
|Used to execute scheduled commands||Used to execute commands periodically|
- Explain load average
Load average is the average system load on Linux servers being calculated over a given period.
The load average of Linux servers will be found using “top” and “uptime” commands.
It is used to keep track of system resources and it is represented by a decimal number starting at 0.00. It tells the user the load that the system has been under currently.
- Define Network Bonding with its advantages
Network bonding is also known as NIC teaming used to connect multiple network interfaces into a single interface for improving the performance and redundancy by increasing network throughput and bandwidth. This NIC teaming has the following advantages
- Load balancing
- Increased uptime
- Name the network bonding modes of Linux
Following are the network bonding modes in Linux
- Mode-0 (balance-RR) is the default mode based on the round-robin policy. It provides fault tolerance and load balancing.
- Mode-1 (active-backup) is based on an active-backup policy. Only one node will respond or work at the time of failure of other nodes.
- Mode-2 (balance-xor) sets an XOR (exclusive-or) for providing load balancing and fault tolerance.
- Mode-3 (broadcast) is based on the broadcast policy that sets a broadcast mode for offering fault tolerance and is used for specific purposes.
- Mode-4 (802.3ad) is based on IEEE 802.3ad standard and it is also known as Dynamic Link Aggregation mode. It sets an IEEE 802.3ad dynamic link aggregation mode to create aggregation groups for sharing the same speed and duplex settings.
- Mode-5 (balance – TLB) is Adaptive TLB (Transmit Load Balancing) for setting TLB mode for fault tolerance and load balancing. Traffic will be loaded based on each slave of the network in this mode.
- Mode-6 (balance – alb) is also known as Adaptive Load Balancing for setting ALB mode for fault tolerance and load balancing and it doesn’t require any special switch support.
- List the ports used for DNS, SMTP, FTP, SSH, DHCP, and Squid
- DNS service is using port no.53
- SMTP service is using port no.25
- The FTP service is using port no.20 for data transfer and port no.21 for connection establishment
- The SSH service is using port no.22
- DHCP service is using port no.67/UDP for DHCP server and 68/UDP for DHCP client.
- Squid service is using port no.3128
- Differentiate Soft and Hard Links
Hard Links are considered a mirror copy of the original file while soft links are considered a symbolic link to the original file.
Hard links share the same inode number and soft links share different inode numbers.
Hard links contain the original contents of the files and soft links will not contain the actual contents but they contain the location of the original file.
In hard links, any changes made to the original file will reflect in the other files directly but any changes or updates made to the soft link will reflect in the original files and hard links directly.
Hard links are not used for linking directories while soft links are used for linking directories. Hard links are faster but soft links are slower.
- What are the three standard streams in Linux?
Standard streams in Linux have based on I/O (Input and Output) communication channels between a program and its environment. Input and output in the Linux platform are distributed over three standard streams and they are as follows
- Standard input (stdin)
- Standard output (stdout)
- Standard Error (stderr)
- Define the Ping Command
Ping in Linux stands for Packet Internet Groper is the command that is used for checking the connection status between source and destination.
This is used to check whether a network is available and if the host is reachable or not.
It is also used to troubleshoot various connectivity issues and verify connectivity at an IP level to a second TCP/IP device and name resolution.
We can use the Ping command to test both the computer name and IP address of the particular computer machine.
- Define Samba with its advantages
Samba is an open-source software suite and it runs several different operating systems such as OpenVMS, IBM, etc.
It offers more secure, fast, and stable file and print services for every client or user SMB (Server Message Block) or CIFS (Central Server Message Block).
- What is the usage of the env command?
The ‘env’ command is a shell command used to print a list of current environmental variables.
Here, the “env” command stands for the environment and it can also run another process in another environment without any modification of the current environment.
It enables us to run programs in a modified and it is used by shell scripts to launch the correct interpreter.
It is also useful for checking if wrong environment variables prevent the application from starting during troubleshooting.’
PHYTHON_PIP_VERSION = 9.0L1
DB_NAME = test
PATH = /usr/local/bin:/usr/local/sbin
LAND = C.UTF = 8
PYTHON_VERSION = 3.4.6
PWD = /
DB_URI = mongodb://database:27017/test
- Explain Pipe in Linux
A pipe is a form of redirection in Linux used to send the output of one command to another command for further processing.
It takes the output from one command and uses it as an input for another and it provides asynchronous execution of commands with a help of buffered I/O routines.
It is the top choice of global companies as it provides more security to the applications and services stored in their machines.
The above “Linux Interview Questions and Answers” are useful for the aspirants who wish to enter the Linux environment.