LINUX Interview Questions
LINUX Interview Questions
1.Be Clear and Frank while prepare resume. Since mostly question wil be
asked based on ur resume.
2.Try to focus more about ur day to day job in resume.
3.Make sure you are clear in basic Linux such as booting, LVM, Architecture,
servermodel which you worked.
4.Before give interview write down your day to day work , server model
information ,your current environment details and review your self.
5.Dont prepare upto last minute it will spoil your mood and confidence.
6.Once interview over note down the Question which they asked. It will help
for next interview.
QUESTIONS :
2. BIOS will start the processor and perform a POST [power on self test] to
check the connected device are ready to use and are working properly.
3. After POST , BIOS will check for the booting device. The boot sector is
always the first sector of the hard disk and BIOS will load the MBR into the
memory.
MBR holds the boot loader of the OS.
7. After kernel is loaded the kernel will take the control of the booting
process
8. Initrd will be loaded which contains drivers to detect hardware (its called
Initialization of RAM Disk)
9. Then it will initialize all the hardware including I/O processors etc.
12. INIT will mount the root partition and other partitions as read/write and
checks for file system errors.
14. Based on the Runlevel, it will load the services and runs the startup
scripts which are located in /etc/rcX.d/ (Network, nfs, SSH etc.)
15. Finally it runs the rc.local script & Now the login prompt will appear.
The great thing about GRUB is that it includes knowledge of Linux file
systems. Instead of using raw sectors on the disk, as LILO does,
GRUB can load a Linux kernel from an ext2 or ext3 file system. It does this
by making the two-stage boot loader into a three-stage boot loader.
A. Stage 1.5 boot loader , it contains extra coe to allow cylinders above
1024, or LBA type drives, to be read.
B. It will be stored on MBR or Boot partition .
C. Stage 1 (MBR) boots a stage 1.5 boot loader that understands the
particular file system containing the Linux kernel image.
D. Basically this module will load the knowledge of Filesystem to Grub to
read the kernel
so ,
# chroot /mnt/sysimage
# grub
# setup (hd0)
# EXIT
Another Method
#linux rescue
# chroot /mnt/sysimage
# /sbin/grub-install /dev/hda
init=/bin/bash
Then save and exit and boot the server. This will launch you straight into a
Bash shell prompt.Then you can remount “/” file system and check
/var/log/messages for any error.
Note : init=/bin/bash (Grub boot loader) or linux init=/bin/bash (if Lilo boot
loader).
2) Once server booted and if it is in Bash shell prompt
#mount -o remount,rw /
3) Now you can check the log messages and try to find the reason for
server pacnic or error.
#more /var/log/messages
Option 2: If the above option not helped then follow the next
3) After the bash shell prompt show up, type the below command
# chroot /mnt/sysimage
#fsck -y /dev/sda2'
Option 3: If the above also not helped then reinstall grub and retry.
In rescue mode.
# chroot /mnt/sysimage
# /sbin/grub-install /dev/hda
>> This tells us that we have two /boot partitions. Then we have to
reinstall the GRUB config on disk (one by one) and try.
#grub> root (hd0,1) //Write the GRUB bootloader on the MBR of the
first disk
grub> setup (hd0)
grub>quit
If you have doubt as to where the root partition is located then try to find a
file in /etc.
Note: You must pay attention to your devices, for me "hd0" is the root disk
and (hd0,1) is /boot partition , and (hd0,1) is my ROOT (/) partition.
mostly / "root" partion will be on LVM.
You might not even have "hd0" mapped out. Review your
"/boot/grub/device.map" file
#cat /boot/grub/device.map
While booting
# passwd
thenreboot system:
# sync
# reboot
or
# mke2fs -n /dev/sda3
7. What is hard link and soft link? How to create symbolic link?
B. Soft or symbolic links are just like hard links. It allows to associate multiple filenames
with a single file. However, symbolic links allows:
An inode is a data structure on a traditional Unix-style file system such as UFS or ext3.
An inode stores basic information about a regular file, directory, or other file system object.
(remember UNIX or Linux never stores file creation time, this is favorite question asked in
UNIX/Linux sys admin job interview)
For examble /opt filesystem's inode usage is high means we have to do below steps
# mkdir /opt/test
# cd /opt/test
# i=1
# while [ $i -lt 10000 ]
> do
> touch $i
> i=`expr $i + 1`
> done
Else you will be watching the terminal for years to get you the prompt or else CTRL + C will
do :-D
#bdf -i /opt
If the NFS file system is hard mounted, the NFS daemons will try repeatedly to contact the
server. The NFS daemon retries will not time out, will affect system performance, and you
cannot interrupt them
If you just mount a file system without specifying hard or soft, the default is a hard mount.
Hard mounts are preferable because of the stateless nature of NFS.
If a client sends an I/O request to the server (such as an ls -la), and the server gets
rebooted, in client machine the process will keep on running.
This preserves data transfers in the event of a server failure
IN SOFT Mount :
A soft mount allows the client to stop trying an operation after a period of time. If the NFS
server goes down at the time of data transfer , it will alert and the process will do down.Thsi
may cause the data corruption.
A soft link will return with an error and fail.
you should only use soft mounts in the cases where client responsiveness is more important
than data integrity.
In another word ..soft mount will allow automatic unmount if the filesystem is idle for a
specified time period
or
1. -0 initr
This option is used in non reliable network, or network having more network congestion.
NFS request will be interrupted when server is not reachable.
2. -o hard
If hard option is specified during nfs mount, user cannot terminate the process waiting for
NFS communication to resume. For ex ..if u ran ls -a command on ur NFS mounted
directory but that time ur NFS server went down means .
The process wont get killed or stopped ..it will wait until the NFS server and mount poit
become available.
3. -o soft
If soft option is specified during nfs mount, user will get error alert when NFS server is not
reachable. This is just inverse of hard mount option. It wont wait for reply if the NFS server
went down , it will alert us and the process will go down.
4. -o Nfsvers=value
If this option is specified during nfs mount NFS client uses particular NFS protocol version to
communicate.
The Difference between HARD and SOFT mount option explained in another POST.
Question 11: Explain TOP command output / Various states of CPU
# us -> User CPU time: The time the CPU has spent running users’ processes that are not
niced.
# sy -> System CPU time: The time the CPU has spent running the kernel and its
processes.
# ni -> Nice CPU time: The time the CPU has spent running users’ process that have been
niced.
# wa -> iowait: Amount of time the CPU has been waiting for I/O to complete.
# hi -> Hardware IRQ: The amount of time the CPU has been servicing hardware interrupts.
# si -> Software Interrupts.: The amount of time the CPU has been servicing software
interrupts
1. #getconf LONG_BIT
2.#uname -a
4.#arch