Categories
Top 50 Linux Interview Questions and Answers
Linux is among the fastest and most powerful operating systems used in computers. Over 90 percent of the world’s fastest computers have Linux OS. If you wish to become a Linux professional in a reputed organization, then this is the right platform to prepare for your job interview. In this Linux Interview Questions blog, you will cover some of the most common interview questions asked during interviews in this domain.
1. What is Linux?
2. What are the components of the Linux system?
System libraries: They are specialized functions or programs that allow application programs or system utilities to access Kernel capabilities. These libraries implement the majority of the operating system’s functionality and do not require kernel module code access permissions.
System Utility: Programs in the System Utility category are in charge of performing specialized, individual-level activities. They are more dependable and also provide users control over the computer.
3. What is LILO?
It handles the following tasks:
1) Locating Linux kernel
2) Identifying other supporting programs and loading them in memory
3) Starting the kernel
The selection of various Kernel images and boot routines is supported by LILO. For this reason, it is known as the boot manager.
4. What does sar provide? Where are the sar logs stored?
When the CPU utilization is close to 100 percent, it indicates that the processing workload primarily demands the CPU. This information helps determine if the system is experiencing a CPU-bound situation.
By default, sar saves its log files in the /var/log/sa/sadd directory, where “dd” represents the current day. These log files are valuable for retrospective analysis and tracking system activity over time.
5. Compare Linux with Windows.
Criteria | Linux | Windows |
Type of OS | Open-source | Proprietary |
Customization | High level of customization | Cannot be changed |
Security | Excellent | Vulnerable to security issues |
6. Suppose, you wish to print a file ‘draft’ with 60 lines on a page. What command would you use?
pr -l60 draft
7. What is LD_LIBRARY_PATH?
setenv—LD_LIBRARY_PATH--$PATH
8. How to check memory stats and CPU stats as a Linux Admin?
9. How to reduce or shrink the size of the LVM partition?
1) Unmount the file system using the unmount command
2) Use the resize2fs command as follows:
resize2fs /dev/mapper/myvg-mylv 10G
lvreduce -L 10G /dev/mapper/myvg-mylv
10. What are the different modes of Network Bonding in Linux?
1) balance-rr or mode 0: The round-robin mode for fault tolerance and load balancing
2) active-backup or mode 1: Sets the active-backup mode for fault tolerance
3) balance-xor or mode 2: Sets an XOR (exclusive-or) mode for fault tolerance and load balancing
4) broadcast or mode 3: Sets a broadcast mode for fault tolerance. All transmissions are sent on all the slave interfaces
5) 802.3ad or mode 4: Sets an IEEE 802.3ad dynamic link aggregation mode and creates aggregation groups that share the same speed and duplex settings
6) balance-tlb or mode 5:Sets a transmit load balancing (TLB) mode for fault tolerance and load balancing
7) balance-alb or mode 6: Sets an active load balancing (ALB) mode for fault tolerance and load balancing
11. How to check and verify the status of the bond interface?
cat /proc/net/bonding/bond0
12. What is LILO?
13. How to check and verify the status of the bond interface?
14. Do you know the Maximum length (in bytes) of the filename in Linux?
15. What are the two different kinds of Linux User Modes?
1) Command Line
2) GUI
16. What is Hard Link?
$ ln [original filename] [link name]
17. What is Soft Link?
$ ln -s [original filename] [link name
18. Explain the features of the Linux system?
2) It offers a prominent feature which is that it is a multiuser system, which implies that several users may share system resources such as memory, ram, and application programs.
3) Portability refers to the capacity of software to run on a variety of hardware platforms in the same way. The Linux kernel and application software may be installed on virtually any hardware platform.
4) Linux is a multiprogramming system, which means it can run many programs at the same time.
5) Linux has a Hierarchical File System (HFS), which offers a standardized structure for storing system and user data files.
19. Why is Linux regarded as a more secure operating system than other operating systems?
1On Linux, only a few people have access to the system. As a result, the virus cannot infect the entire system but it may affect only a few files.
2) Before opening the files, Linux users must first complete the tasks, so that they can protect their systems against flaws.
3) The Linux operating system includes a variety of working environments, including Linux Mint, Debian, Arch, and others, all of which include virus protection.
4) It keeps a log history so that it may quickly see the specifics of the system files afterward.
5) Iptables is a Linux feature that examines the system’s security circle.
6) As Linux users are comparatively fewer in number as compared to other operating systems, security will be enhanced.
20. How can you enhance the security of the password file in Linux?
To minimize this risk, we will make use of the shadow password format that saves the account details in a regular file /etc/passwd as in the traditional method but with the password stored as a single ‘x’ character, i.e., it is not the original password that is actually stored in this file. Meanwhile, a second file /etc/shadow will have the encrypted password, along with the other relevant information, such as the account/password expiration date, etc. Most importantly, the latter file is readable only by the root account, and thus it minimizes the security risk.
21. What are the three standard streams in Linux?
1) Standard Input (stdin)
2) Standard Output (stdout)
3) Standard Error (stderr)
22. What is CLI?
23. What is GUI?
24. Suppose, your FTP Server is hacked and the entire server needs to be restored. How would you restore the original kernel system files?
25. Why should you avoid Telnet to administer a Linux system remotely?
It includes the passing of the login credentials in plain text, i.e., anyone running a sniffer on the network can find the information he/she needs to take control of the device in a few seconds by eavesdropping on a Telnet login session.
26. Name the four Configuration Management Tools used in UNIX-like operating systems.
2) Chef
3) Puppet
4) CFEngine
27. What is the difference between Cron and Anacron?
2) A Cron job can be scheduled by any normal user, while Anacron can be scheduled only by a superuser (a superuser is a special user account used for system administration. Depending on the operating system, the actual name of this account might be root, administrator, admin, or supervisor).
3) Cron expects the system to be up and running, while Anacron doesn’t expect this all the time. In the case of Anacron, if a job is scheduled and the system is down at this time, it will execute the job as soon as the system is up and running.
3) Cron is ideal for servers, while Anacron is ideal for both desktops and laptops.
4) Cron should be used when we want a job to be executed at a particular hour and minute, while Anacron should be used when the job can be executed at any time.
28. Explain various file permissions in Linux?
Read: This read permission allows you to open the file, read it, and list the content of the directory.
Write: This permission gives you the ability to change the contents of a file as well as add, remove, and rename files in <br?directories.
Execute: The file in the directory can be accessed and run by the user. The execute permission must be established before a file may be run.
29. What is the name and path of the main system log?
30. Can we convert a Linux computer into a router in order to enable multiple machines to work on the same Internet connection? If yes, how?
Linux IP Masquerading enables the other ‘internal’ computers that are linked to this Linux system to get connected to the Internet. This Linux feature is available even when these machines do not have their own IP addresses.
Step 1: First of all, we have to make sure that our Linux PC is having an Internet connection, along with a LAN connection. In fact, a Linux PC will be having a PPP connection and an Ethernet card. Step 2: As the default gateway for TCP/IP networking, all the other systems on our LAN use the Linux machine. Hence, we have to use the same DNS addresses provided by the Internet service provider on all our systems.
31. What are the different types of modes in VI editor?
Command Mode/Regular Mode: The default mode for vi editors is Command Mode/Regular Mode. It is typically used to view and write instructions that perform special or unique vi tasks.
Insertion Mode/Edit Mode: You may use this Insertion mode to edit text or insert text into a file. You can also delete the text.
Ex Mode/Replacement Mode: Ex mode is commonly used for file saving and command execution. We can overwrite the text in this mode.
32. In Linux, how would you change the window manager?
Once we are done with this part, the next step is to save the file. This way, a new window manager opens up every time we run a startx, and it becomes the default.
1) KDE = startkde
2) GNOME = gnome-session
3) BlackBox = blackbox
4) FVWM = fvwm
5) Window Maker = wmaker
6) IceWM = icewm
33. Mention various Linux directory commands
cd: cd refers to “change directory”. We use this command to change the present working directory to the specifically required directory. The syntax of this command is $ cd
Is: ls refers to “list”. We use this command to view the full list of files and directories in the present working directory. The syntax of this command is $ ls.
mkdir: mkdir refers to “make directory”. We use this command to create directories in Linux. The syntax of this command is $ mkdir .
rmdir: rmdir refers to “remove directory”. We use this command to remove or delete any directory on the command line. The syntax of this command is $ rmdir .
34. How are shadow passwords given in Linux?
First, the entries in the shadowed file, which don’t exist in the main file, are removed. Then, the shadowed entries that don’t have ‘x’ as the password in the main file are updated. Any missing shadowed entries are also added. Finally, passwords in the main file are replaced with ‘x’. These programs can be used for initial conversion as well to update the shadowed file if the main file is edited by hand.
35. List out some Linux distributors?
1) Linux Mint: It is a stable and reliable operating system. Mate and Cinnamon are two of the most popular desktop environments used in Linux Mint.
2) Debian: It is a Linux distribution that stands for stability, reliability, and a well-oiled release process.
3) Manjaro: It provides a pleasurable experience for both novice and seasoned users.
4) Ubuntu: Ubuntu is based on Debian and is available in desktop and server variants.
5) openSUSE: It is a fantastic choice for both novice and experienced users.
36. What do you know about Linux Shell and its types?
1) CSH (C Shell)
2) BASH (Bourne Again Shell)
3) KSH (Korn Shell)
4) TCSH (Tenex C Shell)
5) ZSH(Z Shell)
37. What shell does a Linux Administrator assign to a POP3 mail-only account?
POP3 is basically used for downloading mail-to-mail programs. So for the illegal downloading of emails on the shell, this account is assigned to the /bin/false shell or the /bin/nologin shell. Both shells are the same as they do the same work of rejecting the user login to the shell.
The main difference between these two shells is that the false shell shows the incorrect code and any unusual coding when a user logs in to it, whereas the nologin shell simply tells us that no such account is available. Therefore, the nologin shell is used often in Linux.
38. If a volume group named VG0 already exists and we need to extend this volume group up to 4 GB, how do we do it?
2) If there is not enough free space in the VG0 volume group, you may need to add physical volumes (disks) to increase the available space. This step assumes that you have additional disks available. If you already have sufficient free space,
3) Extend the logical volume: Once you have sufficient free space in the VG0 volume group, you can extend the logical volume (LV) within it. Use the lvextend command to increase the size of the LV to 4 GB.
4) Resize the file system: Finally, you need to resize the file system on the LV to utilize the newly allocated space. The specific command depends on the file system type.
39. What is YUM?
40. What is the role of Kudzu?
41. What is the difference between ext2 and ext3 file systems?
2) The most important difference between ext2 and ext3 is that ext3 supports journaling.
3) After an unexpected power failure or system crash (also called an unclean system shutdown), each ext2 file system must be checked for consistency by the e2fsck program. This is a time-consuming process and during this time, any data on the volumes is unreachable.
4)The journaling provided by the ext3 file system means that this sort of a file system check is no longer necessary after an unclean system shutdown. The only time a consistency check occurs while using ext3 is in certain rare hardware failure cases, such as hard drive failures. The time to recover an ext3 file system after an unclean system shutdown does not depend on the size of the file system or on the number of files. Rather, it depends on the size of the journal used to maintain consistency. The default journal size takes almost a second to recover, depending on the speed of the hardware.
42. In Linux, how can I figure out where a file is stored?
43. In Linux, how do you stop a running process?
44. How to enable ACLs for the /home partition?
1) Check if ACLs are already enabled: Use the mount command to check if the /home partition is mounted with the acl option. Look for an entry that includes acl in the options field.
Backup important data: Before making any changes, it’s always a good practice to back up important data on the /home partition. This step helps ensure that you have a copy of the data in case anything goes wrong during the process.
45. Is there any relation between the modprobe.conf file and network devices?
[root@localhost ~]# cat /etc/modprobe.conf
alias eth0 b44
Here, b44 is the kernel module for network device eth0.
We can confirm whether this module “b44” is present or not by the following command
[root@localhost ~]# lsmod |grep b44
b44 29005 0
46. What daemon is used for scheduling commands?
-r: Removes the current crontab
-e: Edits the current crontab using the editor specified by the VISUAL or EDITOR environment variables
crontab [ -u user ] file
crontab [ -u user ] { -l | -r | -e }
47. What daemon is used for scheduling commands?
-r: Removes the current crontab
-e: Edits the current crontab using the editor specified by the VISUAL or EDITOR environment variables
48. Differentiate between Linux and Unix
Linux | Unix |
Offers both paid and free OS | Cost varies with the levels |
It is portable | It is non-portable |
The installation process of Linux does not involve any hardware components | Hardware components are needed to install Unix |
It is developed by a worldwide Linux community. | It is developed by AT&T developers. |
49. Mention the difference between BASH and DOS
BASH | DOS |
Bourne Again Shell | Disk Operating System |
Case Sensitive commands | Non Case sensitive commands |
/ represents directory separator | / represents command argument |
represents escape character | represents directory separator |
Follows conventional naming | Does not follow conventional naming |
50. What command can you use to make a tape archive file of /home directory and send it to the /dev/tape device?
tar -cvf / dev/tape /home