Linux Interview Questions and Answers For Graduates Part-1
1.What is LILO?
• LILO is Linux Loader is a boot loader for Linux. It is used to load Linux into the memory and start the Operating system. LILO can be configured to boot other operating systems as well. LILO is customizable, which means that if the default configuration is not correct, it can be changed. Config file for LILO is lilo.conf.
• LILO is also a code snippet which 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 the memory
• The selection of various kernel images and boot routines is supported by LILO. For this reason, it is known as boot manager.
2.You wish to print a file ‘draft’ with 60 lines on a page. What command would you use?
The command used: pr -l60 draft
– The default page length when using pr is 66 lines.
– The -l option specifies a different length.
3.What is LD_LIBRARY_PATH?
• LD_LIBRARY_PATH is an environment variable. It is used for debugging a new library or a non-standard library. It is also used to identify what directories need to be searched. Path to search for directories needs to given.
• The variable can be set using setenv—LD_LIBRARY_PATH–$PATH
• It is used to search for the shared objects / dynamic libraries by the operating system for extendable functionality at runtime.
4.Name a service that you should disable (which acts both as Web and FTP Server) on a Linux Server.
The finger service should be disabled because a remote user can get important information about the system by using that command.
5.What does Sar provide? Where are Sar logs stored?
Sar collects, reports, or saves system activity information, sar 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 forth) and limitation of problems in this manner. If CPU utilization is near 100 % (user + nice + system), the workload sampled is CPU-bound.
By default, log files of Sar command is located at /var/log/sa/sadd file, where dd parameter indicates the current day.
6.How to check Memory stats and CPU stats as a Linux admin?
Using ‘free’ & ‘vmstat’ command, we can display the physical and virtual memory statistics, respectively. With the help of ‘sar’ command, we can see the CPU utilization & other stats.
7.How to reduce or shrink the size of LVM partition?
Below are the logical steps to reduce size of LVM partition :
-Unmount the filesystem using unmount command,
– Use resize2fs command , e.g resiz2fs /dev/mapper/myvg-mylv 10G
-Now use the lvreduce command as lvreduce -L 10G /dev/mapper/myvg-mylv
The above Command will shrink the size LVM partition and fixes the filesystem size to 10GB.
8.What are the different modes of Network bonding in Linux?
Below are list of modes used in Network Bonding:
• balance-rr or 0 – round-robin mode for fault tolerance and load balancing.
• active-backup or 1 – Sets 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 slave interfaces.
• 802.3ad or 4 – Sets an IEEE 802.3ad dynamic link aggregation mode. Creates aggregation groups that share the same speed & duplex settings.
• balance-tlb or 5 – Sets a Transmit Load Balancing (TLB) mode for fault tolerance & load balancing.
• balance-alb or 6 – Sets an Active Load Balancing (ALB) mode for fault tolerance & load balancing.
9.How to check and verify the status of the bond interface?
Using the command ‘cat /proc/net/bonding/bond0,’ we can check what mode is enabled and what LAN cards are used in this bond. In this example, we have one one bond interface. However, we can have multiple bond interfaces like bond1, bond2 and so on.
10.How can you enhance the security of password file?
Linux keep user account information in a text file called /etc/passwd. This file also stores one way encrypted password. It is accessed by several tools to get user information, which is a security risk, so file need to ‘Word Readable.’ To minimize the security risk, you can use shadow password format. This method saves account information in regular file /etc/passwd. However, the password is stored as a single “x” character (not actually stored in this file). A second file, called “/etc/shadow” contains encrypted password as well as other information such as account or password expiration values, etc. The /etc/shadow file is readable only by the root account and is therefore less of a security risk