Top 50 Linux Interview Questions & Answers 2023 - Intellipaat

Process Advisors

ey-logo
*Subject to Terms and Condition

Categories

Top Answers to Linux Interview Questions

CTA

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. Let’s get a quick look at these frequently asked questions:

Q1. What is Linux?
Q2. Compare Linux with Windows.
Q3. What are the components of the Linux system?
Q4. What is LILO?
Q5. Suppose, you wish to print a file ‘draft’ with 60 lines on a page. What command would you use?
Q6. What is LD_LIBRARY_PATH?
Q7. Name a service that you should disable (which acts both as web and FTP servers) on a Linux server.
Q8. What does sar provide? Where are the sar logs stored?
Q9. How to check memory stats and CPU stats as a Linux Admin?
Q10. How to reduce or shrink the size of the LVM partition?

We have categorized the Linux interview questions and answers into three parts as mentioned below:
1. Basic

2. Intermediate

3. Advanced

Watch this Linux Interview Questions And Answers Video on YouTube:

Youtube subscribe

Basic Linux Interview Questions for Freshers

1. What is Linux?

Linux is an open-source operating system based on UNIX. It was named after the founder “Linus Torvalds”. He introduced Linux with the primary goal to offer an operating system at a free or very reasonable price for users. It is based on the Linux kernel and is compatible with different hardware platforms such as Intel, MIPS, HP, IBM, SPARC, and Motorola hardware platforms. Linux’s mascot, a penguin named Tux, is another popular feature. Linux offers a user-friendly environment where they can easily modify and create variations in the source code.

2. 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

3. What are the components of the Linux system?

There are three primary components of the Linux system which are explained below.

Kernel: The kernel is the most important component of Linux. It is in charge of the operating system’s primary functions. It is made up of a number of modules that interface directly with the hardware. Kernel offers the necessary abstraction for system or application programs to mask low-level hardware information.

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.

4. What is LILO?

LILO (Linux Loader) is a boot loader for Linux. It is used to load Linux into memory and start the operating system. LILO can be configured to boot other operating systems as well. LILO is customizable, i.e., if the default configuration is not correct, it can be changed. lilo.conf is the configuration file for LILO. LILO is also a code snippet that loads PC BIOS into the main memory at the time of starting the computer system.

It handles the following tasks:

  • Locating Linux kernel
  • Identifying other supporting programs and loading them in memory
  • 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.

5. Suppose, you wish to print a file ‘draft’ with 60 lines on a page. What command would you use?

The command used for this purpose would be as follows:

pr -l60 draft

Note: The default page length when using pr is 66 lines. The -l option specifies a different length.

Get 100% Hike!

Master Most in Demand Skills Now !

6. What is LD_LIBRARY_PATH?

LD_LIBRARY_PATH is an environment variable used for debugging a new library or a non-standard library. It is also used to identify the directories that need to be searched for; in order to do this, the path to search for the directories needs to be specified.

The variable can be set using the following:

setenv—LD_LIBRARY_PATH--$PATH

It is used to search for the shared objects/dynamic libraries by the operating system for extendable functionality at the runtime.

Prepare yourself for the Linux certification with this comprehensive Linux Training in London!

7. Name a service that you should disable (which acts both as web and FTP servers) on a Linux server.

The finger service should be disabled on a Linux server because a remote user can get important information about the system by using this command.

To disable this service use command: sudo systemctl disable vsftpd

8. What does sar provide? Where are the sar logs stored?

The sar command in Linux is a valuable tool for collecting and analyzing system activity information. It reports various aspects of system performance, such as CPU usage, memory utilization, disk activity, network traffic, and more. When troubleshooting performance issues, sar enables you to review historical data and identify the causes of high load on specific system components.

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.

9. How to check memory stats and CPU stats as a Linux Admin?

Using the free and vmstat commands, we can display the physical and virtual memory statistics, respectively. With the help of the sar command, we can see the CPU utilization and other stats.

Memory Stats

10. How to reduce or shrink the size of the LVM partition?

Below are the logical steps to reduce the size of the LVM partition:

  • Unmount the file system using the unmount command
  • Use the resize2fs command as follows:
resize2fs /dev/mapper/myvg-mylv 10G
  • Then, use the lvreduce command as follows:
lvreduce -L 10G /dev/mapper/myvg-mylv

This way, we can reduce the size of the LVM partition and fix the size of the file system to 10 GB.

11. What are the different modes of Network Bonding in Linux?

Below is the list of various modes used in Network Bonding:

  • balance-rr or mode 0: The round-robin mode for fault tolerance and load balancing
  • active-backup or mode 1: Sets the active-backup mode for fault tolerance
  • balance-xor or mode 2: Sets an XOR (exclusive-or) mode for fault tolerance and load balancing
  • broadcast or mode 3: Sets a broadcast mode for fault tolerance. All transmissions are sent on all the slave interfaces
  • 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
  • balance-tlb or mode 5: Sets a transmit load balancing (TLB) mode for fault tolerance and load balancing
  • balance-alb or mode 6: Sets an active load balancing (ALB) mode for fault tolerance and load balancing

For more details, check out Intellipaat’s Linux Training in Sydney!

12. How to check and verify the status of the bond interface?

Using the following command, we can check which mode is enabled and what LAN cards are used in this bond:

cat /proc/net/bonding/bond0

In this example, we have a single bond interface. However, we can have multiple bond interfaces like bond1, bond2, and so on.

Career Transition

13. Do you know the Maximum length (in bytes) of the filename in Linux?

The maximum length of a filename is 255 bytes. In this filename, the pathname is not included, so the total length of the pathname and filename may easily surpass 255 characters.

14. What are the two different kinds of Linux User Modes?

The following are the two types of Linux user modes:

  • Command Line
  • GUI

15. What is Hard Link?

In Linux, Hard links can be defined as another name for an already existing file. For each file, we can generate an unlimited number of hard links. They have the ability to generate links for other hard connections. We can use the `Is-I` command to find out the total number of hard links in a file. And we can create Hard links using the following command:

$ ln [original filename] [link name]

16. What is Soft Link?

Soft link is also known as a symbolic link. Soft links are files that, in most cases, lead to another file. It just links to another entry somewhere in the file system and does not include any data in the destination file. These kinds of connections can be utilized across several file systems. The following command can be used to create soft links:

$ ln -s [original filename] [link name]

CTA

Check out this video on Linux Shell Tutorial:

Youtube subscribe

Intermediate Linux Interview Questions

17. Explain the features of the Linux system?

The key features of the Linux system are as follows:

  • Linux is a community-based major project which is freely available open-source code. Multiple teams collaborate to improve the capabilities of this operating system, which is always growing.
  • 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.
  • 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.
  • Linux is a multiprogramming system, which means it can run many programs at the same time.
  • Linux has a Hierarchical File System (HFS), which offers a standardized structure for storing system and user data files.
  • Linux contains a custom interpreter application that allows users to run operating system program commands and instructions.
  • User security is provided by Linux through authentication mechanisms such as password protection, limited access to particular files, and data encryption.

18. Why is Linux regarded as a more secure operating system than other operating systems?

Linux has become more popular in the technology industry in terms of security. There are several reasons why Linux is more secure than other operating systems.

  • On 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.
  • Before opening the files, Linux users must first complete the tasks, so that they can protect their systems against flaws.
  • The Linux operating system includes a variety of working environments, including Linux Mint, Debian, Arch, and others, all of which include virus protection.
  • It keeps a log history so that it may quickly see the specifics of the system files afterward.
  • Iptables is a Linux feature that examines the system’s security circle.
  • As Linux users are comparatively fewer in number as compared to other operating systems, security will be enhanced.

Learn Linux from Top Experts by Enrolling in Linux Training in Dubai.

19. How can you enhance the security of the password file in Linux?

It is in the test file named ‘/etc/passwd’ that Linux usually keeps its user account details, including the one-way encrypted passwords. However, this file can be accessed with the help of different tools, which might throw security issues.

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.

To enable shadow password use the command: pwconv

20. What are the three standard streams in Linux?

In Linux, standard streams are channel communication of input and output between a program and its environment. In the Linux system, input and output are spread among three standard streams which are:

  1. Standard Input (stdin)
  2. Standard Output (stdout)
  3. Standard Error (stderr)

21. What command can you use to make a tape archive file of /home directory and send it to the /dev/tape device?

The command used here is:

tar -cvf /dev/tape /home

The -xvf option is used to extract files from an archive.

Expert Linux professionals are in high demand. Take this Linux Course in Toronto and join the big league!

22. What is CLI?

The acronym CLI stands for Command Line Interface. The user can input declarative instructions into this interface to direct the machine tasks. It communicates with a software program by issuing commands in the form of text lines. It also interacts with computer terminals; the interface receives text lines and transforms them into operating system commands. CLI offers great flexibility.

23. What is GUI?

A GUI (Graphical User Interface) is a type of interface between humans and machines that allows people to interact with electronic devices via graphical icons and visual indications. The inclusion of graphical components makes it easier to interact with the system, as well as provides additional appeal through images, icons, and colors, rather than having to memorize and write commands. Users will find it simpler to engage with the system if certain graphical components or icons are used. It is visually appealing and enables increased productivity.

24. Suppose, your FTP Server is hacked and the entire server needs to be restored. How would you restore the original kernel system files?

We cannot restore the entire operating system from the tape backup device. Therefore, we should reinstall the core operating system and then restore the system configuration files and user data from the tape backup device.

25. Why should you avoid Telnet to administer a Linux system remotely?

Telnet uses the most insecure method for communication. It sends data across the network in plain text format, and anybody can easily find out the password using the network tool.

Telnet

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. Differentiate between Linux and Unix

The differences between Linux and Unix are mentioned in the following table:

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.
It is highly flexible and compatible It is less flexible and compatible compared to Linux. 
It is used in both software and hardware, frameworks, etc.  It is used in servers, workstations, etc.

27. Name the four Configuration Management Tools used in UNIX-like operating systems.

  • Ansible
  • Chef
  • Puppet
  • CFEngine

Certification in Full Stack Web Development

28. Mention the difference between BASH and DOS

The key differences between BASH and DOS are given below:

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

29. What is the difference between Cron and Anacron?

There are many differences between Cron and Anacron as given below:

  • Minimum granularity with Cron is in minutes, while it is in days with Anacron.
  • 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).
  • 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.
  • Cron is ideal for servers, while Anacron is ideal for both desktops and laptops.
  • 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.

30. Explain various file permissions in Linux?

In Linux, each file and directory has three categories of owners which are User, Group, and Others. For all three owners, there are three sorts of permissions defined as mentioned below:

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 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.

31. Which command is used to check the number of files, disk space, and each user’s defined quota?

The repquota command is used to check the status of a user’s defined quota, along with the disk space and the number of files used.

repquota

This command gives a summary of the user’s quota, i.e., how much space and files are left for the particular user. Each user has a defined quota in Linux. This is done mainly for security as it restricts files from unwanted access. The quota can be given to a single user or to a group of users.

32. What is the name and path of the main system log?

By default, the main system log is /var/log/messages. This file contains all messages and scripts written by a user. By default, all scripts are saved in this file. This is the standard system log file, which contains messages from all system software, non-kernel boot issues, and messages that go to dmesg. The dmesg file is a system file that is written upon the system boot.

Want to be Linux Certified? Learn about Linux Certification!

33. 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?

Yes! We can convert a Linux PC into a router so that it can act as an IP gateway for a network. This process of turning a Linux machine into a router is referred to as IP Masquerade, which is basically a Linux networking function that is quite similar to the one-to-many network address translation servers.

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.

In Linux, we can perform IP Masquerading by following the below steps:

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.
Step 3: Now, for enabling IP forwarding, we will use the following command:

echo 1 > /proc/sys/net/ipv4/ip_forward

For checking whether we have IP forwarding enabled already, we can use the following:

sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0

Or, we will just check out the value i /proc/sys/net/ipv4/ip_forward:

~]# cat /proc/sys/net/ipv4/ip_forward
0

Step 4: Finally, we will run /sbin/iptables for setting up those rules that enable IP Masquerading.

Become a Full Stack Web Developer

34. What are the different types of modes in VI editor?

The VI editor (Visual Editor) is a basic text editor that appears in most Linux distributions. The following are the main varieties of modes usable in the 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.

35. In Linux, how would you change the window manager?

The /.xinitrc file lets us change the window manager that we will use while logging into the X window session. The dot (.) here tells us that this particular file is a hidden. It also means that this file will not be present when we carry out a normal directory listing. In order to set up a window manager, the following command should be saved in this file:

exec 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.

Now, let’s check out the commands used for starting some very common desktop environments and window managers:

  • KDE = startkde
  • GNOME = gnome-session
  • BlackBox = blackbox
  • FVWM = fvwm
  • Window Maker = wmaker
  • IceWM = icewm

Advanced Linux Interview Questions and Answers for Experienced Professionals

36. Mention various Linux directory commands

There are five fundamental Linux directory commands for working with files and directories, as listed below:

  • pwd:  pwd refers to “print working directory”. We use this command to display the path of the current working directory. The syntax of this command is $ pwd. 
  • 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 <path to new directory>. 
  • 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 <name (and path if required) of new directory>.
  • 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 <name (and path if required) of directory>.

37. How are shadow passwords given in Linux?

In Linux, the pwconv command is used for providing the shadow passwords. Shadow passwords are given for better system security. This command creates the file /etc/shadow and changes all passwords to ‘x’ in the /etc/passwd file.

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.

Get certified from the top Linux Course in Singapore now!

38. List out some Linux distributors?

We have a lot of Linux distributors, so we’ll go through a few of the more significant ones. 

  • 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.
  • Debian: It is a Linux distribution that stands for stability, reliability, and a well-oiled release process.
  • Manjaro: It provides a pleasurable experience for both novice and seasoned users.
  • Ubuntu: Ubuntu is based on Debian and is available in desktop and server variants.
  • openSUSE: It is a fantastic choice for both novice and experienced users.

39. What daemon is used for scheduling commands?

The crontab command is used for scheduling commands to run at a later time.

Syntax:

crontab [ -u user ] file
crontab [ -u user ] { -l | -r | -e }

Options:

  • -l: Displays the current crontab entries
  • -r: Removes the current crontab
  • -e: Edits the current crontab using the editor specified by the VISUAL or EDITOR environment variables

crontab

When a user exits from the editor, the modified crontab will be installed automatically. Each user can have their own crontab and though these are files in /var, they are not intended to be edited directly.

If the -u option is given, then the crontab gives the name of the user whose crontab is to be tweaked. If it is given without this option, then it will display the crontab of the user who is executing the command.

40. What do you know about Linux Shell and its types?

The Linux shell is software that serves as a user interface between the user and the kernel. By writing programs, instructions, and scripts on the shell, users may execute instructions and communicate with the kernel. The Linux shell is software that allows users to run commands. It takes human-readable commands as input and translates them into kernel-friendly language.

The main five types of shells in Linux are:

  • CSH (C Shell)
  • BASH (Bourne Again Shell)
  • KSH (Korn Shell)
  • TCSH (Tenex C Shell)
  • ZSH(Z Shell)

41. What shell does a Linux Administrator assign to a POP3 mail-only account?

A Linux Administrator assigns a POP3 mail-only account to the /bin/false shell. However, assigning a bash shell to a POP3 mail-only account gives the user the login access, which is usually avoided. The /bin/nologin shell can also be used. This shell is provided to the user when we don’t want to give shell access to the user. The user cannot access the shell, and it rejects shell login on the server as in Telnet. It is mainly meant for the security of the shells.
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.

42. 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?

To extend an existing volume group named VG0 to a size of 4 GB, you would typically follow these steps:

1. Check the available space: Use the vgdisplay command to check the available space in the VG0 volume group. Look for the “Free PE / Size” field to determine how much free space is currently available.

vgdisplay VG0

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, you can skip to step 3.

  • Add physical volumes: Use the pvcreate command to initialize the additional disks and make them available for use in the volume group.
pvcreate /dev/sdb1      # Replace /dev/sdb1 with the appropriate device name for your disk
  • Extend volume group: Use the vgextend command to add the newly created physical volumes to the VG0 volume group.
vgextend VG0 /dev/sdb1  # Replace /dev/sdb1 with the appropriate device name for your disk

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.

lvextend -L 4G /dev/VG0/LVname   # Replace LVname with the name of the logical volume you want to extend

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.

For ext2/ext3/ext4 file systems, use the resize2fs command.

resize2fs /dev/VG0/LVname   # Replace LVname with the name of the logical volume

For XFS file systems, use the xfs_growfs command.

xfs_growfs /dev/VG0/LVname   # Replace LVname with the name of the logical volume

After completing these steps, your VG0 volume group should be extended to 4 GB, and the file system on the logical volume should be resized to utilize the additional space.

43. Is there any relation between the modprobe.conf file and network devices?

Yes, this file assigns a kernel module to each network device.

Example:

[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

44. What is YUM?

YUM stands for Yellowdog Updater Modified because it is based on YUP, the Yellowdog Updater. Yellowdog is a version of Linux for the Power Architecture hardware and is RPM-based, just like Red Hat Enterprise Linux and Fedora. YUP, and later YUM, were written by the Linux community as a way to maintain an RPM-based system.

45. What is the role of Kudzu?

Kudzu is used to detect new hardware. Red Hat Linux runs a hardware discoverer, called Kudzu. When attempting to identify a serial port, Kudzu resets the serial port. This stops the serial console. Kudzu is configured from the following file:

/etc/sysconfig/kudzu

Kudzu can be prevented from resetting hardware, by setting the configuration parameter SAFE to ‘yes.’

46. What is the difference between ext2 and ext3 file systems?

  • The ext3 file system is an enhanced version of the ext2 file system.
  • The most important difference between ext2 and ext3 is that ext3 supports journaling.
  • 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.
  • 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.

47. Explain the /proc file system?

The /proc file system is a virtual file system that provides detailed information about Linux Kernel, hardware, and running processes. Files under the /proc directory are named as virtual files.

proc file system

Since /proc contains virtual files, it is called a virtual file system. These virtual files have unique qualities. Most of them are listed as zero bytes in size. Virtual files such as /proc/interrupts, /proc/meminfo, /proc/mounts, and /proc/partitions provide an up-to-the-moment glimpse of the system’s hardware. Others, such as the /proc/filesystems file and the /proc/sys/ directory, provide system configuration information and interfaces.

48. In Linux, how can I figure out where a file is stored?

To find the path to the file, use the locate command. If you wish to locate the locations of a file named sample.txt, use the following command:

$ locate sample.txt

49. How would you create an ext4 file system?

We can create an ext4 file system with the following command:

# mke2fs -t ext4 /dev/DEV

50. In Linux, how do you stop a running process?

Every process has its own identifier. We must first locate the process id in order to terminate it. The “ps” command displays a list of all currently active processes, along with their ids. The “kill” command is then used to end the process.

51. How to enable ACLs for the /home partition?

To enable Access Control Lists (ACLs) for the /home partition, you’ll need to follow these general steps:

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.

mount | grep /home

If you see an entry that includes acl in the options field, it means ACLs are already enabled. You can skip to step 4.

2. 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.

3. Edit the /etc/fstab file: To enable ACLs permanently, you need to modify the /etc/fstab file.

  • Open the /etc/fstab file using a text editor. For example:
sudo nano /etc/fstab
  • Locate the entry for the /home partition. It may look similar to:
UUID=<partition-UUID>   /home   <filesystem-type>   defaults   0   2
  • Modify the options field to include acl. It should look like:
UUID=<partition-UUID>   /home   <filesystem-type>   defaults,acl   0   2

Make sure to replace <partition-UUID> with the actual UUID of the /home partition and <filesystem-type> with the appropriate file system type.

Save the changes and exit the text editor.

4. Remount the partition: After modifying the /etc/fstab file, you need to remount the /home partition for the changes to take effect.

  • Run the following command to remount the partition:
sudo mount -o remount /home

5. Verify ACLs are enabled: Use the mount command again to verify that the /home partition is now mounted with the acl option.

mount | grep /home

If you see an entry that includes acl in the options field, it means ACLs are now enabled for the /home partition.

Once ACLs are enabled, you can use commands like getfacl and setfacl to manage access control lists on files and directories within the /home partition.

Course Schedule

Name Date Details
Python Course 30 Sep 2023(Sat-Sun) Weekend Batch
View Details
Python Course 07 Oct 2023(Sat-Sun) Weekend Batch
View Details
Python Course 14 Oct 2023(Sat-Sun) Weekend Batch
View Details

5 thoughts on “Top 50 Linux Interview Questions and Answers”

Leave a Reply

Your email address will not be published. Required fields are marked *