Best Interview Questions on Linux:
All of us are aware of the fact that, for managing all the hardware resources of your laptop or desktop and for enabling proper communication between software and your computer hardware, there is one word without which software would not function i.e. ‘Operating System’ OS. Just like Windows XP, Windows 7, Windows 8, MAC; LINUX is such an operating system.
LINUX is referred to as the most used operating system and is best known for its efficiency and fast performance. LINUX was first introduced by Linux Torvalds and is based on Linux Kernal.
It can run on different hardware platforms manufactured by HP, Intel, IBM, etc.
In this article, we will see multiple Linux interview questions and answers which will not only help to prepare for interviews but will also help in learning all about Linux. Questions include Linux admin, Linux commands interview questions, etc.
Table of Contents:
LINUX Interview Question And Answers
Here we go.
Q #1) What do you understand by Linux Kernal? Is it legal to edit it?
Answer: ‘Kernal’ basically refers to that core component of the computer operating system that provides basic services for the other parts as well as interacts with user commands. When it comes to ‘Linux Kernal’, it is referred to as low-level system software providing an interface for user-level interactions.
Linux Kernal is considered as free and open-source software which is capable of managing hardware resources for the users. As it is released under General Public Licence (GPL), it becomes legal for anyone to edit it.
Q #2) Differentiate between LINUX and UNIX?
Answer: Although there are multiple differences between LINUX and UNIX, enlisted points in the below table cover all the major differences.
LINUX | UNIX |
---|---|
LINUX is an open source software development and free operating system used for computer hardware & software, game development, PCs, etc. | UNIX is an operating system which is basically used in Intel, HP, internet servers, etc. |
LINUX has priced as well as freely distributed and downloaded versions. | Different versions/flavours of UNIX have different price structures. |
Users of this operating system could be anyone including home users, developers, etc. | This operating system was basically developed for mainframes, servers and workstations except for OSX which is designed such that it can be used by anyone. |
File support system includes Ext2, Ext3, Ext4, Jfs, Xfs, Btrfs, FAT, etc. | File support system includes jfs, gpfs, hfs, etc. |
BASH (Bourne Again Shell) is the Linux default shell i.e. text mode interface which supports multiple command interpreters. | Bourne shell serves as the text mode interface which is now compatible with many others including BASH. |
LINUX provides two GUIs, KDE and Gnome. | Common desktop environment was created which serves as a GUI for UNIX. |
Examples: Red Hat, Fedora, Ubuntu, Debian, etc. | Examples: Solaris, All Linux |
It provides higher security and has about 60-100 viruses listed till date. | It is also highly secured and has about 85-120 viruses listed till date. |
Q #3) Enlist the basic components of LINUX?
Answer: Linux operating system basically consists of 3 components. They are:
- Kernel: This is considered as the core part and is responsible for all major activities of the Linux operating system. Linux Kernel is considered as free and open-source software that is capable of managing hardware resources for the users. It consists of various modules and interacts directly with the underlying hardware.
- System Library: Most of the functionalities of the operating system are implemented by System Libraries. These act as a special function using which application programs accesses Kernel’s features.
- System Utility: These programs are responsible for performing specialized, individual-level tasks.
Q #4) Why we use LINUX?
Answer: LINUX is used widely because it is completely different from other operating systems where every aspect comes with something extra i.e. some additional features.
Some of the major reasons to use LINUX are listed below:
- It is an open-source operating system where programmers get the advantage of designing their own custom OS
- Software and the server licensing required to install Linux is completely free and can be installed on many computers as required
- It has low or minimum but controllable issues with viruses, malware, etc
- It is highly secured and supports multiple file systems
Q #5) Enlist the features of the Linux operating system?
Answer: Following are some important features of the LINUX operating system:
- Linux Kernel and application programs can be installed on any kind of hardware platform and thus are considered portable.
- It serves the purpose of multitasking by serving various functions simultaneously.
- It provides security services in three ways namely, Authentication, Authorization, and Encryption.
- It supports multiple users to access the same system resource but by using different terminals for operation.
- Linux provides a hierarchical file system and its code is freely available to all.
- It has its own application support (to download and install applications) and customized keyboards.
- Linux distros provide live CD/USB to their users for installation.
Q #6) Explain LILO?
Answer: LILO (Linux Loader) is the boot loader for the Linux operating system to load it into the main memory so that it can begin its operations. Bootloader here is a small program that manages a dual boot. LILO resides in MBR (Master Boot Record).
Its major advantage is that it allows the fast bootup of Linux when installing in the MBR.
Its limitation lies in the fact that it is not possible for all computers to tolerate modification of MBR.
Q #7) What is Swap space?
Answer: Swap space is the amount of physical memory that is allocated for use by Linux to hold some concurrent running programs temporarily. This condition usually occurs when RAM does not have enough memory to support all concurrent running programs. This memory management involves the swapping of memory to and from physical storage.
There are different commands and tools available to manage the Swap space usage.
Q #8) What do you understand by the Root account?
Answer: As the name suggests, it is like a system administrator account which gives you the ability to fully control the system. The root account serves as the default account whenever Linux is installed.
Below mentioned functions can be performed by the Root account:
- Create user accounts
- Maintain user accounts
- Assign different permissions to each account created and so on.
Q #9) Explain the virtual desktop?
Answer: When there are multiple windows available on the current desktop and there appears the problem of minimizing and maximizing windows or restoring all the current programs, there ‘Virtual Desktop’ serves as an alternative. It allows you to open one or more programs on a clean slate.
Virtual desktops are basically stored on a remote server and serve the following benefits:
- Cost savings as the resources can be shared and allocated as and when required.
- Resources and energy are more efficiently used.
- Data integrity is improved.
- Centralized administration.
- Fewer compatibility issues.
Q #10) Differentiate between BASH and DOS?
Answer: The basic differences between BASH and DOS can be understood from the below table.
BASH | DOS |
---|---|
BASH commands are case sensitive. | DOS commands are not case sensitive. |
‘/’ character used as a directory separator. ‘\’ character acts as an escape character. | ‘/’ character: serves as a command argument delimiter. ‘\’ character: serves as a directory separator. |
File naming convention includes: 8 character file name followed by a dot and 3 characters for the extension. | No file naming convention is followed in DOS. |
Q #11) Explain the term GUI?
Answer: GUI stands for the Graphical User Interface. GUI is considered as the most attractive and user-friendly because it consists of the usage of images and icons. These images and icons are clicked and being manipulated by the users for the purpose of communication with the system.
Advantages of GUI:
- It allows users to navigate and operate the software with the help of visual elements.
- The more intuitive and rich interface is possible to be created.
- Fewer chances of occurrence of errors as complex, multi-step, dependent tasks are easily grouped together.
- Productivity is enhanced with the means of multitasking as with a simple click of the mouse, the user is able to maintain multiple open applications and transitions between them.
Disadvantages of GUI:
- End-users have less control over the operating system and file systems.
- Although it is easier to use a mouse and keyboard for navigation and controlling the operating system, the whole process is a bit slow.
- It requires more resources because of the elements that need to be loaded such as icons, fonts, etc.
Q #12) Explain the term CLI?
Answer: CLI stands for Command Line Interface. It is a way for humans to interact with computers and is also known as the Command-line user interface. It relies on textual request and response transaction process where user types declarative commands to instruct the computer to perform operations.
Advantages of CLI
- Very flexible
- Can easily access commands
- Much faster and easier to use by expert
- It does not use much CPU processing time.
Disadvantages of CLI
- Learning and remembering type commands is hard.
- Have to be typed precisely.
- It can be very confusing.
- Surfing web, graphics, etc are a few tasks that are hard or impossible to do on the command line.
Q #13) Enlist some Linux distributors (Distros) along with its usage?
Answer: Different parts of LINUX say kernel, system environment, graphical programs, etc are developed by different organizations. LINUX Distributions (Distros) assemble all these different parts of Linux and give us a compiled operating system to be installed and used.
There are around six hundred Linux distributors. Some of the important ones are:
- UBuntu: It is a well known Linux Distribution with a lot of pre-installed apps and easy to use repositories libraries. It is very easy to use and works like a MAC operating system.
- Linux Mint: It uses cinnamon and mates desktop. It works on Windows and should be used by newcomers.
- Debian: It is the most stable, quicker and user-friendly Linux Distributors.
- Fedora: It is less stable but provides the latest version of the software. It has a GNOME3 desktop environment by default.
- Red Hat Enterprise: It is to be used commercially and to be well tested before release. It usually provides a stable platform for a long time.
- Arch Linux: Every package is to be installed by you and is not suitable for beginners.
Q #14) How can you determine the total memory used by LINUX?
Answer: It is always required to keep a check on the memory usage in order to find out whether the user is able to access the server or the resources adequately. There are roughly 5 methods that determine the total memory used by Linux.
This is explained as below:
- Free command: This is the most simple command to check memory usage. For Example, ‘$ free –m’, the option ‘m’ displays all the data in MBs.
- /proc/meminfo: The next way to determine memory usage is to read /proc/meminfo file. For Example, ‘$ cat /proc/meminfo’
- Vmstat: This command basically lays out the memory usage statistics. For Example, ‘$ vmstat –s’
- Top command: This command determines the total memory usage as well as also monitors the RAM usage.
- Htop: This command also displays memory usage along with other details.
Q #15) Explain the 3 kinds of file permissions under LINUX?
Answer: Every file and directory in Linux are assigned three types of owners namely ‘User’, ‘Group’, and ‘Others’. The three kinds of permissions defined for all the three owners are:
- Read: This permission allows you to open and read the file as well as list the contents of the directory.
- Write: This permission allows you to modify the contents of the file as well as allows adding, removing and renaming files stored in the directories.
- Execute: Users can access and run the file in the directory. You cannot run a file unless the execute permission is set.
Q #16) What is the maximum length for any file name under LINUX?
Answer: The maximum length for any file name under Linux is 255 characters.
Q #17) How permissions are granted under LINUX?
Answer: A system administrator or the owner of the file can grant permissions using the ‘chmod’ command. Following symbols are used while writing permissions:
- ‘+’ for adding permission
- ‘-‘ for denying permission
Permissions also include a single letter which denotes
u : user; g: group; o: other; a: all; r: read; w: write; x: execute.
Q #18) What are the different modes when using the vi editor?
Answer: The 3 different kinds of modes in vi editor are enlisted below:
- Command Mode/ Regular Mode
- Insertion Mode/ Edit Mode
- Ex Mode/ Replacement Mode
Q #19) Explain the Linux Directory commands along with the description?
Answer: The Linux Directory commands along with descriptions are as follows:
- pwd: It is a built-in command which stands for ‘print working directory’. It displays the current working location, working path starting with/and directory of the user. Basically, it displays the full path to the directory you are currently in.
- Is: This command list out all the files in the directed folder.
- cd: This stands for ‘change directory’. This command is used to change to the directory you want to work from the present directory. We just need to type cd followed by the directory name to access that particular directory.
- mkdir: This command is used to create an entirely new directory.
- rmdir: This command is used to remove a directory from the system.
Q #20) Differentiate between Cron and Anacron?
Answer: Difference between Cron and Anacron can be understood from the below table:
Cron | Anacron |
---|---|
Cron allows the user to schedule tasks to be executed every minute. | Anacron allows the user to schedule tasks to be run either on a specific date or the first available cycle after the date. |
Tasks can be scheduled by any normal user and are basically used when tasks have to be completed/executed at a particular hour or minute. | Anacron can be used only by super users and is used when a task has to be executed irrespective of hour or minute. |
It is ideal for servers | It is ideal for desktops and laptops |
Cron expects the system to be running 24x7. | Anacron does not expects the system to be running 24x7. |
Q #21) Explain the work of Ctrl+Alt+Del key combination on the Linux operating system?
Answer: The work of Ctrl+Alt+Del key combination on the Linux operating system is the same as is for Windows i.e. to restart the system. The only difference is that there is no confirmation message displayed and a system is rebooted directly.
Q #22) What is the role of case sensitivity in affecting the way commands are used?
Answer: Linux is considered a case sensitive. Case sensitivity can sometimes serve as the reason for displaying different answers for the same command as you might enter the different formats of commands each time. In terms of case sensitivity, the command is the same but the only difference occurs with regard to uppercase and lowercase letters.
For Example,
cd, CD, Cd are different commands with different outputs.
Q #23) Explain Linux Shell?
Answer: For executing any commands user uses a program known as the shell. Linux shell is basically a user interface used for executing the commands and communicating with Linux operating system. Shell does not use the kernel to execute certain programs, create files, etc.
There are several shells available with Linux which includes the following:
- BASH (Bourne Again SHell)
- CSH ( C Shell)
- KSH ( Korn Shell)
- TCSH
There are basically two types of Shell commands
- Built-in shell commands: These commands are called from the shell and executed directly within the shell. Examples: ‘pwd’, ’help’, ’type’, ’set’, etc.
- External/ Linux commands: These commands are totally shell independent, have their own binary and are located in the file system.
Q #24) What is a Shell script?
Answer: As the name suggests, the shell script is the script written for the shell. This is a program file or says a flat text file where certain Linux commands are executed one after another. Although the execution speed is slow, the Shell script is easy to debug and can also simplify everyday automation processes.
Q #25) Explain the features of a Stateless Linux server?
Answer: The word stateless itself means ‘no state’. When on a single workstation, no state exists for the centralized server, and then the stateless Linux server comes into the picture. Under such conditions, scenarios like keeping all the systems on the same particular state can occur.
Some of the features of Stateless Linux server are:
- Stores prototype of every machine
- Store snapshots
- Store home directories
- Uses LDAP which determines the snapshot of state to be run on which system.
Q #26) What are system calls used for process management in Linux?
Answer: Process management in Linux uses certain system calls. These are mentioned in below table with a brief explanation
[table “” not found /]Q #27) Enlist some Linux to file content commands?
Answer: There are many commands present in Linux which are used to look at the contents of the file.
Some of them are enlisted below:
- head: Displays the beginning of the file
- tail: Displays the last part of the file
- cat: Concatenate files and print on the standard output.
- more: Displays the content in pager form and is used to view the text in the terminal window one page or screen at a time.
- less: Displays the content in pager form and allows backward and single line movement.
Q #28) Explain Redirection?
Answer: It is well known that every command takes input and displays output. Keyboard serves as the standard input device and the screen serves as the standard output device. Redirection is defined as the process of directing data from one output to another or even cases exist where output serves as input data for another process.
There are basically three streams available in which input and output of the Linux environment are distributed.
These are explained as below:
- Input Redirection: ‘<’ symbol is used for input redirection and is numbered as (0). Thus it is denoted as STDIN(0).
- Output Redirection: ‘>’ symbol is used for output redirection and is numbered as (1). Thus it is denoted as STDOUT(1).
- Error Redirection: It is denoted as STDERR(2).
Q #29) Why is Linux considered more secure than other operating systems?
Answer: Linux is an open-source operating system and nowadays it is growing rapidly in the tech world/market. Although, the entire code written in Linux can be read by anyone, then also it is considered more secure because of the following reasons:
- Linux provides its user with limited default privileges which are basically restricted to the lower levels .i.e. in the case of any virus attack, it will reach only local files and folders where the system-wide damage is saved.
- It has a powerful auditing system that includes detailed logs.
- Enhanced features of IPtables are used in order to implement a greater level of security for the Linux machine.
- Linux has tougher program permissions before installing anything on your machine.
Q #30) Explain command grouping in Linux?
Answer: Command grouping is basically done by the use of braces ‘()’ and parenthesis ‘{}’. Redirection is applied to the entire group when the command is grouped.
- When commands are placed within the braces, then they are executed by the current shell. Example, (list)
- When the commands are placed within the parenthesis, then they are executed by a subshell. Example, {list;}
Q #31) What is Linux pwd (print working directory) command?
Answer: Linux pwd command displays the whole path of the current location you are working in starting from the root ‘/’. For Example, to print the current working directory enter “$ pwd”.
It can be used for the below purposes:
- To find the full path of the current directory
- Store the full path
- Verify the absolute and physical path
Q #32) Explain the Linux ‘cd’ command options along with the description?
Answer: ‘cd’ stands for change directory and is used to change the current directory on which the user is working.
cd syntax : $ cd {directory}
Following purposes can be served with ‘cd’ commands:
- Change from current to a new directory
- Change directory using the absolute path
- Change directory using the relative path
Few of the ‘cd’ options are enlisted below
- cd~: Brings you to the home directory
- cd-: Brings you to the previous directory
- . : Bring you to the parent directory
- cd/: Takes you to the entire system’s root directory
Q #33) What is know about grep commands?
Answer: Grep stands for ‘global regular expression print’. This command is used for matching a regular expression against text in a file. This command performs pattern-based searching and only the matching lines are displayed as output. It makes use of options and parameters that are specified along with the command line.
For example: Suppose we need to locate the phrase “our orders” in an HTML file named “order-listing.html”.
Then the command will be as follows:
$ grep “our orders” order-listing.html
The grep command outputs the entire matching line to the terminal.
Q #34) How to create a new file and modify an existing file in vi editor? Also, enlist the commands used to delete information from vi editor.?
Answer: The commands are:
- vi filename: This is the command used to create a new file as well as modify an existing file.
- View filename: This command opens an existing file in read-only mode.
- X: This command deletes the character which is under the cursor or before the cursor location.
- dd: This command is used to delete the current line.
Q #35) Enlist some Linux networking and troubleshooting commands?
Answer: Every computer is connected to the network internally or externally for the purpose of exchanging information. Network troubleshooting and configuration are essential parts of and network administration. The networking commands enable you to quickly troubleshoot connection issues with another system, check the response of another host, etc.
A network administrator maintains a system network that includes network configuration and troubleshooting. Mentioned below are few commands along with their description:
Mentioned below are few commands along with their description
- Hostname: To view the hostname (domain and IP address) of the machine and to set the hostname.
- Ping: To check if the remote server is reachable or not.
- ifconfig: To display and manipulate route and network interfaces. It displays network configuration. ‘ip’ is the replacement of ifconfig command.
- netstat: It displays network connections, routing tables, interface statistics. ‘ss’ is the replacement of netstat command which is used to get more information.
- Traceroute: It is a network troubleshooting utility that is used to find the number of hops required for a particular packet to reach the destination.
- Tracepath: It is the same as traceroute with a difference that it does not require root privileges.
- Dig: This command is used to query the DNS name servers for any task related to the DNS lookup.
- nslookup: To find DNS related query.
- Route: It shows the details of the route table and manipulates the IP routing table.
- mtr: This command combines ping and track path into a single command.
- Ifplugstatus: This command tells us whether the network cable is plugged in or not.
Conclusion
Thus concluding this article with the learning fact that Linux is a complete operating system having different versions that suit any type of user (new/experienced). Linux is considered as a lot more user-friendly, stable, secure and reliable which can run non-stop for years without a single reboot.
This article has covered every part of Linux which can ask any interview questions. I hope you have got a clear idea about the topic. Just keep learning and all the best.