Linux System Administrator Interview Questions
and Answers.
In this article we will discuss top Linux system admin interview
questions with the Answers for experience professionals. Below mentioned
questions may help the readers to clear Linux interviews.
Q1: How To check Memory status , CPU status & uptime of
server ?
Answer: Using ‘free’, ‘vmstat’,'top','mpstat','uptime'
command we can display the physical and virtual memory statistics respectively.
With the help of ‘sar’ command we see the CPU utilization & other status.
Q2: What does SAR provides and at
which location SAR logs are stored ?
Answer: SAR (System Activity Reporter) Collect, report, or save system
activity information. The default version of the SAR command (CPU utilization
report) might be one of the first facilities the user runs
to begin system activity investigation, because it monitors major
system resources.
By default log files of SAR command is located
at /var/log/sa/sadd file, where the dd parameter indicates the current
day.
Q3: Why LVM is required ?
Answer: LVM stands for Logical Volume Manager , to resize file
system’s size online we required LVM partition in Linux. Size of LVM partition
can be extended and reduced using the lvextend & lvreduce commands
respectively. But in RHEL-7/CentOS-7 lvreduce command is removed.
Q4: How to increase the size of LVM
partition ?
Answer: Below are the Logical Steps :
– Use the lvextend command (lvextend -L +100M /dev/<Name of
the LVM Partition> , in this example we are extending the size by 100MB.
– resize2fs /dev/<Name of the LVM Partition> # for
ext2/3/4 file system
- xfs_growfs /dev/<Name of the LVM Partition> # for
xfs file system
– check the size of partition using ‘df -h’ command
Q5: How to reduce or shrink the size of LVM partition ?
Answer: Below are the logical Steps to reduce size of LVM
partition :
-Umount the filesystem using umount command,
-use resize2fs command , e.g resiz2fs /dev/mapper/myvg-mylv 10G
-Now use the lvreduce command , e.g lvreduce -L 10G
/dev/mapper/myvg-mylv
Above Command will shrink the size & will make the
filesystem size 10GB.
Q6: How to create partition from the raw disk ?
Answer: Using fdisk utility we can create partitions from the
raw disk. Below are the steps to create partition from the raw disk :
– fdisk /dev/hd* (IDE) or /dev/sd* (SCSI)
– Type n to create a new partition
– After creating partition , type w command to write the
changes to the partition table.
Q7: Where the kernel modules are located ?
Answer: The ‘/lib/modules/kernel-version/’ directory stores all
kernel modules or compiled drivers in Linux operating system. Also with ‘lsmod’
command we can see all the installed kernel modules.
Q8: What is umask ?
Answer: umask stands for ‘User file creation mask’, which
determines the settings of a mask that controls which file permissions are set
for files and directories when they are created.
Q9: How to set the umask permanently for a user?
Answer: To set this value permanently for a user, it has to be
put in the appropriate profile file which depends on the default shell of the
user.
Q10: How to change the default run level in linux ?
Answer: To change the run level we have to edit the file
“/etc/inittab” and change initdefault entry ( id:5:initdefault:). Using ‘init’
command we change the run level temporary like ‘init 3’ , this command will
move the system in run level 3.
Q11: How to share a directory using nfs ?
Answer: To share a directory using nfs , first edit the
configuration file ‘/etc/exportfs’ , add a entry like
‘/<directory-name> <ip or Network>(Options)’
and then restart the nfs service.
Q12: How to check and mount nfs share ?
Answer: Using ‘showmount’ command we can see what directories
are shared via nfs e.g ‘showmount -e <ip address of nfs server>’.Using
mount command we can mount the nfs share on Linux machine.
Q13: What are the default ports used for SMTP,DNS,FTP,DHCP,SSH
and squid ?
Answer:
Service Port
SMTP 25
DNS 53
FTP 20 (data Transfer)
, 21 ( Connection established)
DHCP 67/UDP(dhcp server) ,
68/UDP(dhcp client)
SSH 22
Squid 3128
Q14: What is Network Bonding ?
Answer: Network bonding is the aggregation of multiple Lan cards
into a single bonded interface to provide fault tolerance and high performance.
Network bonding is also known as NIC Teaming.
Q15: What are the different modes of Network bonding in
Linux ?
Answer: 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.
Q16: How to check and verify the status the bond interface.
Answer: Using the command ‘cat /proc/net/bonding/bond0’ , we can
check which mode is enabled and what Lan cards are used in this bond. In this
example we have one only one bond interface but we can have multiple bond
interface like bond1,bond2 and so on.
Q17: How to check default route and routing table ?
Answer: Using the Commands ‘netstat -nr’ and ‘route -n’ we can
see the default route and routing tables.
Q18: How to check which ports are listening in my Linux Server ?
Answer: Use the Command ‘netstat –listen’ and ‘lsof -i’
Q19: List the services that are enabled at a particular run
level in Linux server ?
Answer: In RHEL 6 of below, with the help of command ‘chkconfig
–list | grep 5:on’ we can list all the service that are enabled in run level5.
For other run levels just replace 5 with the respective run level.
In the RHEL7 command ‘systemctl -a’
Q20: How to enable a service at a particular run level ?
Answer: We can enable a service using the Command ‘chkconfig
<Service-Name> on –level 3’ in w RHEL 6 and below, but in RHEL 7 and above
‘systemctl enable service-name’
Q21: How to upgrade Kernel in Linux ?
Answer: We should never upgrade Linux Kernel , always install
the new kernel using rpm command because upgrading a kernel can make your Linux
box in a unbootable state.
Q22: How To scan newly assigned LUNS on Linux box without
rebooting ?
Answer: There are two ways to scan newly assigned LUNS :
Method:1 if sg3 rpm is installed , then run the command
‘rescan-scsi-bus.sh’
Method:2 Run the Command , echo ” – – – ” >
/sys/class/scsi_host/hostX/scan
Q23: How to find WWN numbers of HBA cards in Linux Server ?
Answer: We can find the WWN numbers of HBA cards using the
command ‘systool -c fc_host -v | grep port_name’
Q24: How to add & change the Kernel parameters ?
Answer: To set the kernel parameters in Linux , first edit the
file ‘/etc/sysctl.conf’ after making the changes save the file and run the
command ‘sysctl -p’ , this command will make the changes permanently without
rebooting the machine.
Q25: /mount point usage is 99%, however did not find any file to
delete, how did you clear up the / usage and bring back to normal usage?
Answer: When lot of processes are running in Linux server there
are lot of .TMP files which be created in background for support. You cannot
identify use of / file system in this case using lsof would help.
#### To check delete Temp files
# lsof | grep deleted
### Clear Temp Files by killing PID’s
# lsof | grep deleted | grep “.TMP” | awk ‘{print $2 }’ | xargs
kill -9
### To delete Temp Files.
lsof | grep deleted | grep “.TMP” | awk ‘{print $9 }’ | xargs rm
-f
Q26: What is zombie process, how
zombie processes will impact system performance ?
Answer: Zombie process or defunct process is a process that has
completed execution but still has an entry in the process table. It is a
process in the “Terminated state”. This occurs for child processes , where the
entry is still needed to allow the parent process to read its child’s exit
status.
Using top and ps command you can check zombie processes.
Q27: if you have scheduled a task to be run at 2 PM but it has
not been executed what will you do ?
Answer:
1st Will check cron service is running
2nd Will check crontab entry has proper details
3rd Always use full path while scheduling
scripts/programs
4th Check cron logs /var/log/cron
Q28: Explain crontab field with example
Answer: The crontab is a list of commands that you want to run
on a regular schedule
Linux Crontab Format
MIN HOUR DOM MON DOW CMD
Crontab Fields and Allowed Ranges (Linux Crontab Syntax)
Field Description Allowed Value
MIN Minute field 0 to 59
HOUR Hour field 0 to 23
DOM Day of Month 1-31
MON Month field 1-12
DOW Day Of Week 0-6
CMD Command
Any command to be executed.
The time field uses 24 hours format. So, for 8 AM use 8, and for
8 PM use 20.
30 08 10 06 * /home/maverick/full-backup
30 – 30th Minute
08 – 08 AM
10 – 10th Day
06 – 6th Month (June)
* – Every day of the week
Q29: There are three users Ravi,
Shekhar & Srikanth you have to give access to ftp, telnet and ssh to Ravi user,
only ssh to Shekhar user, only telnet to Srikanth user. How will you configure
?
Answer:
#visudo
Cmnd_Alias FTP = /bin/ftp
Cmnd_Alias TELNET = /bin/telnet
Cmnd_Alias SSH = /bin/ssh
ravi ALL=(ALL) NO PASSWD: FTP, TELNET, SSH
Shekhar ALL=(ALL) NO PASSWD: SSH
Srikanth ALL=(ALL) NO PASSWD: TELNET
Q30: How will you
install packages.
Answer: You can use below command to install packages
#yum install mysql
#rpm -ivh rpm-name
#apt-get install packagename
Q31: How will you check dependencies
of packages?
Answer:
#yum deplist mysql
Q32: Which of the following directory will hold the network configuration
files ?
Answer:
/etc/sysconfig/network-scripts/
No comments:
Post a Comment