You are on page 1of 12

LINUX Interview Questions : PART 1

Hi Friends...i planned to update interview questions and answers for LINUX


admins. Hope this will help you to refresh your knowledge at the time of
interview perparation.

Few points before start,

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.

For L1 & L2 Admin Interview:

Maximum the Question will be on below area

1.Booting procedure of linux server


2.user administration
3.LVM -FS creation/ extend / FS issues & recover
4.Software install / remove / update - RPM or YUM
5.Basic services config /troubleshoot - E.G : NFS ,FTP , SAMBA , DNS ,
DHCP
6.Utilization issues - CPU , MEMORY , DISK
7.Hardware errors and troubleshoot
8.PAtch installation / roll back

Ok Now we can start look into questions and answers

QUESTIONS :

1.Explain Booting Procedure?


2.What is stage 1.5 Bootloader ?
3.How will you reinstall GRUB?
4.How to resolve booting issues in linux?
5.How to reset root password or recover root password
6.What is Super Block? How will you recover it?

Question 1: Explain Booting procedure or steps in Linux?

1. Once System powered on, it automatically invokes BIOS

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.

4. Then boot loader takes the control of the booting process.

5. GRUB is the boot loader for Linux.

6. Depending on the boot option selected the kernel is loaded first.

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.

10. Kernel will mounts the root partition as read-only

11. INIT is loaded as the first process.

12. INIT will mount the root partition and other partitions as read/write and
checks for file system errors.

13. Sets the System Clock, hostname etc..

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.

Question 2: What is stage 1.5 boot loaded in linux?

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 ,

Stage 1 Boot loaded is : MBR


Stage 1.5 Boo loader : e2fs_stage1_5
Stage 2 Boot loader is : GRUB

Question 3: How to reinstall GRUB?

A.Boot up using RHEL4 disk.

B.Enter into rescue mode

#linux rescue (hit ok)

C. Then follow below commands

# chroot /mnt/sysimage

# grub

# find /boot/grub/stage1 or find /grub/stage1


root(hd0,0) //example o/p

Now install the GRUB

# setup (hd0)

# EXIT

Another Method

#linux rescue

# chroot /mnt/sysimage

# /sbin/grub-install /dev/hda

Question 4: Linux Booting Issues : How to solve ??

Option 1: init not found error


Option 2: Run fsck on all FS in rescue mode
Option 3: Reinstall GRUB
Option 4: Recover grub.conf / grub configuration

Option 1: For normal panic and "init not found" error.

Error : "init not found" displayed

1) Launch the system to Bash shell prompt

Reboot the server and interrupt to edit the GRUB.

Edit grub and enter the below in last

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

1) Boot from the Linux First CD (boot CD).

2) Type “boot rescue” at Linux boot prompt.

3) After the bash shell prompt show up, type the below command

# chroot /mnt/sysimage

a) Run fsck and Check for any disk error

#fdisk -l /dev/sda //check how many partion you have

then run fsck on each partition

#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

Option 4: If a system has issues with the GRUB configuration

(possibly caused by incorrect changes to the the GRUB configuration file,


installation of another OS, changes to device ordering due to hardware or
BIOS changes, etc.)

# grub> find /boot/grub/grub.conf (or) grub>find /grub/grub.conf (or)


find /boot/grub/stage1
(hd0,1)
(hd1,2)

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

#grub> find /etc/fstab


(hd0,1)

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

Question 5 : How to recover or rest Root password in LINUX?

While booting

1. Select the kernel


2. Press the "e" key to edit the entry
3. Select second line (the line starting with the word kernel)
4. Press the "e" key to edit kernel entry so that you can append single
user mode
5. Append the letter "S" (or word Single) to the end of the (kernel) line
6. Press ENTER key
7. Now press the b key to boot the Linux kernel into single user mode
8. At prompt type passwd command to reset password:

You need to mount at least / and other partitions:


# mount -t proc proc /proc
# mount -o remount,rw /

Change the root password,

# passwd

thenreboot system:
# sync
# reboot

Question 6: What is super Block and how will u recover it ?

The blocks used for two different purpose:

1. Most blocks stores user data aka files (user data).


2. Some blocks in every file system store the file system's metadata.

So what the hell is a metadata?

File system type


Size
Status
Information about other metadata structures

To find super block

#dumpe2fs /dev/sda3|grep -i superblock

or
# mke2fs -n /dev/sda3

To repair file system by alternative-superblock use command as follows:

# e2fsck -f -b 8193 /dev/sda3

in PART 2 - we are going to see the below Questions and answers:

7. What is hard link and soft link? How to create symbolic link?

8. What is INODE ? How to reduce inode utilization?

9. What is HARD and SOFT mount in NFS ?

10. Explain NFS mount options ?

11. CPU states in TOP or Explain o/p of TOP command

12. How to check architecture of Linux server OS

Question 7: What is hard link and soft link? How to


create symbolic link?

A. Hard links cannot link directories.


Cannot cross file system boundaries.

B. Soft or symbolic links are just like hard links. It allows to associate multiple filenames
with a single file. However, symbolic links allows:

To create links between directories.


Can cross file system boundaries.

How do I create symbolic link?


You can create symbolic link with ln command:

#ln -s /path/to/file1.txt /path/to/file2.txt

(inode number will be same for hard linked file )

#ln /mades/file1 /mades/file2 - ( create hard link)

Question 8: What is INODE ? How to reduce inode


utilization?

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.

=> File type (executable, block special etc)


=> Permissions (read, write etc)
=> Owner
=> Group
=> File Size
=> File access, change and modification time

(remember UNIX or Linux never stores file creation time, this is favorite question asked in
UNIX/Linux sys admin job interview)

How to reduce inode usage in File system?

For examble /opt filesystem's inode usage is high means we have to do below steps

# bdf -i /opt : check the FS usage

Create a test directory on your filesystem;

# mkdir /opt/test

Create a script that will create 10000 null files.

# 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

once files are created do

#bdf -i /opt

Question 9 : What is HARD and SOFT mount in NFS ?

In HARD mount ...

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

Question 10 : Explain NFS mount options ?

Syntax to mount NFS FS:


#mount -t vfstype [-o options] NFS Servername:/exporteddirectory /mount point

or

#mount -t nfs -o options host:/remote/export /local/directory

Mount options explained below :

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.

For example - TCP

# mount -t nfs -o tcp 192.168.1.4:/mnt/array1/RHEL5 /data/


# mount | grep -i tcp
192.168.1.4:/mnt/array1/RHEL5 on /data type nfs (rw,tcp,addr=192.168.1.4)

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

Question 12: How to check architecture of Linux OS

We can use below commands to check the architecture of server OS,

1. #getconf LONG_BIT

2.#uname -a

3.#grep flags /proc/cpuinfo

4.#arch

5.#file /bin or file bc

You might also like