*Friday CLOSED

Timings 10.00 am - 08.00 pm

Call : 021-3455-6664, 0312-216-9325 DHA 021-35344-600, 03333808376, ISB 03333808376

Linux Interview Questions and Answers in Germany Berlin, Munich, Frankfurt

image_pdfSave PDFimage_printPrint
Linux Interview Q&A

Top Linux Interview Questions and Answers

Here we have compiled a set of most asked Linux interview questions so that you can face the Linux interview with confidence. This set includes questions on LILO (Linux Loader), how to shrink the size of LVM, enhancing password security, Cron and Anacron, how to convert Linux computer into a router, YUM, ext2 and ext3 file systems, and much more. Learn Linux from Omni Academy’s Linux Training to fast-track your career!

Top Answers to Linux Interview Questions

1. Compare Linux with Windows.

CriteriaLinuxWindows
Type of OSOpen-sourceProprietary
CustomizationHigh level of customizationCannot be changed
SecurityExcellentVulnerable to security issues

2. 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. The config file for LILO is lilo.conf. 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.

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

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

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

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

In Linux, the sar command collects, reports, or saves system activity information, and it serves to log and evaluate a variety of information regarding system activity. With performance problems, sar also permits retroactive analysis of the load values for various sub-systems (CPUs, memory, disks, interrupts, network interfaces, and so on). If CPU utilization is near to 100 percent, the sampled workload is considered to be CPU-bound.

By default, the log files of the sar command are located at the /var/log/sa/sadd file, where the dd parameter indicates the current day.

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

Enroll in our Linux Training to get a clear understanding of the Linux concepts!

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

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

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

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

For more details, check out Omni Academy’s Linux Training !

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

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

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

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

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

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

  • Ansible
  • Chef
  • Puppet
  • CFEngine

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

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

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.

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

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

Check out this video on Linux Tutorial:

Learn for free ! Subscribe to our youtube Channel.

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

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

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

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.

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

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

  • First, we would create a physical volume (/dev/sda7) of size 4 GB.
  • Then, we would run the following command:
vgextend VG0 /dev/sda7

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

# lsmod |grep b44 b44 29005 0

26. What is YUM?

YUM stands for Yellow dog Updater, Modified because it is based on YUP, the Yellow dog Updater. Yellow Dog 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.

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

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

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

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.

30. How would you create an ext4 file system?

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

# mke2fs -t ext4 /dev/DEV

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

  • Add the following entry in /etc/fstab:
LABEL=/home /home ext3 acl 1 2
  • Then, remount the /home partition with the acl option:
mount -t ext3 -o acl /dev/sda3 /home

To understand Linux concepts better, sign up for our Linux Course today!

Related Courses -Learn Online Now!

RPA (Robotic Process Automation)

Machine Learning with 9 Practical Applications

Mastering Python – Machine Learning

Data Sciences with Python Machine Learning 

Data Sciences Specialization
Diploma in Big Data Analytics

Learn Internet of Things (IoT) Programming
Oracle BI – Create Analyses and Dashboards
Microsoft Power BI with Advance Excel

Join FREE – Big Data Workshop 

sharing is caring

Leave a Reply


ABOUT US

OMNI ACADEMY & CONSULTING is one of the most prestigious Training & Consulting firm, founded in 2010, under MHSG Consulting Group aim to help our customers in transforming their people and business - be more engage with customers through digital transformation. Helping People to Get Valuable Skills and Get Jobs.

Read More

Contact Us

Get your self enrolled for unlimited learning 1000+ Courses, Corporate Group Training, Instructor led Class-Room and ONLINE learning options. Join Now!
  • Head Office: A-2/3 Westland Trade Centre, Shahra-e-Faisal PECHS Karachi 75350 Pakistan Call 0213-455-6664 WhatsApp 0334-318-2845, 0336-7222-191, +92 312 2169325
  • Gulshan Branch: A-242, Sardar Ali Sabri Rd. Block-2, Gulshan-e-Iqbal, Karachi-75300, Call/WhatsApp 0213-498-6664, 0331-3929-217, 0334-1757-521, 0312-2169325
  • ONLINE INQUIRY: Call/WhatsApp +92 312 2169325, 0334-318-2845, Lahore 0333-3808376, Islamabad 0331-3929217, Saudi Arabia 050 2283468
  • DHA Branch: 14-C, Saher Commercial Area, Phase VII, Defence Housing Authority, Karachi-75500 Pakistan. 0213-5344600, 0337-7222-191, 0333-3808-376
  • info@omni-academy.com
  • FREE Support | WhatsApp/Chat/Call : +92 312 2169325
WORKING HOURS

  • Monday10.00am - 7.00pm
  • Tuesday10.00am - 7.00pm
  • Wednesday10.00am - 7.00pm
  • Thursday10.00am - 7.00pm
  • FridayClosed
  • Saturday10.00am - 7.00pm
  • Sunday10.00am - 7.00pm
WhatsApp Us