Linux OR Unix Interview Questions
1) What is GRUB
Ans GNU GRUB is a Multiboot boot loader. It was derived from GRUB, the GRand Unified Bootloader,
which was originally designed and implemented by Erich Stefan Boleyn.
Briefly, a boot loader is the first software program that runs when a computer starts. It is
responsible for loading and transferring control to the operating system kernel software
(such as the Hurd or Linux). The kernel, in turn, initializes the rest of the operating
system (e.g. GNU)
2) Explain Linux Boot Process
Ans http://www.thegeekstuff.com/2011/02/linux-boot-process/
3) Which files are called for user profile by default when a user gets login
Ans $HOME/.bash_profile, $HOME/.bash_bashrc
4) Which file needs to update if srequired to change default runlevel 5 to 3
Ans File is /etc/inittab and required to change below lines:
id:5:initdefault: to id:3:initdefault:
5) What command used for showing user info like Login Name, Canonical Name, Home Directory,Shell etc..
Ans FINGER command can be used i.g; finger username
6) What is inode number
Ans 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
iNode number also called as index number, it consists following attributes:
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)
File deletion time
Number of links (soft/hard)
Extended attribute such as append only or no one can delete file including root user
(immutability)
Access Control List (ACLs)
Following command will be used to show inodes of file and folders:
ls -i
Following command will show complete info about any file or folders with inode number
stat file/folder
Files/Folders can also be deleted using inode numbers with following command:
find out the inode number using 'ls -il' command then run below command
find . -inum inode_number -exec rm -i {} \;
7) How can we increase disk read performance in single command
Ans blockdev command
This is sample output - yours may be different.
# Before test
$ blockdev --getra /dev/sdb
256
$ time dd if=/tmp/disk.iso of=/dev/null bs=256k
2549+1 records in
2549+1 records out
668360704 bytes (668 MB) copied, 6,84256 seconds, 97,7 MB/s
real 0m6.845s
user 0m0.004s
sys 0m0.865s
# After test
$ blockdev --setra 1024 /dev/sdb
$ time dd if=/tmp/disk.iso of=/dev/null bs=256k
2435+1 records in
2435+1 records out
638390272 bytes (638 MB) copied, 0,364251 seconds, 1,8 GB/s
real 0m0.370s
user 0m0.001s
sys 0m0.370s
8) .... command to change user password expiration time
Ans CHAGE
9) Command used to lock user password
Ans usermod -L username
10) How many default number of Shells available and what are their names?
Ans SH, BASH, CSH, TCSH, NOLOGIN, KSH
11) Which file defines the attributes like UID, PASSWORD expiry, HOME Dir create or not while
adding user
Ans /etc/login.defs
12) ...... command used for changing authentication of linux system to LDAP/NIS/SMB/KERBOS
Ans authconfig
13) ...... command used for changing the attributes of any file
Ans chattr
14) What is the path of network (ethX) configuration files
Ans /etc/sysconfig/network-scripts/ethX
15) How can we change speed and make full duplex settings for eth0
Ans We can do this with below given 2 methods:
ethtool -s eth0 speed 100 duplex full
ethtool -s eth0 speed 10 duplex half
OR
mii-tool -F 100baseTx-HD
mii-tool -F 10baseT-HD
16) File which stores the DNS configuration at client side
Ans /etc/resolve.conf
17) Main configuration file and command used for exporting NFS directories and it's deamons
Ans /etc/exports and exportfs -av , deamons are quotad, portmapper, mountd, nfsd and nlockmgr/status
18) What is command to check ports running/used over local machine
Ans netstat -antp
19) What is the command to check open ports at remote machine
Ans nmap
20) What is the difference between soft and hard links
Ans Soft Links => 1) Soft link files will have different inode numbers then source file
2) If original file deleted then soft link file be of no use
3) Soft links are not updated
4) Can create links between directories
5) Can cross file system boundaries
Hard Links => 1) Hard links will have the same inode number as source file
2) Hard links can not link directories
3) Can not cross file system boundaries
4) Hard links always refers to the source, even if moved or removed
21) How to setup never expired user password
Ans chage -E never username
22) Restricting insertion into file if full permission are assigned to all
Ans chattr +i filename
23) Display or Kill all processes which are accessing any folder/file
Ans Display User who are using file/folder : fuser -u file/folder
Kill All Processes which are using file/folder: fuser -k file/folder
24) Kill any user's all processes
Ans killall -u username
25) How can we have daily system analysis and reports over mail
Ans Use logwatch
26) How can we rotate logs using logrotate without performing any operation like move and gzip'ng over original file and then creating new file (which is very lengthy process)
Ans We can use "logrotate"'s "copytruncate" option which will simply copy original file and
truncate original file :)
27) Command to collect detailed information about the hardware and setup of your system
Ans dmidecode , sysreport
28) Command to check PCI devices vendor or version
Ans lspci
29) What is the difference between cron and anacron
Ans Cron :
1) Minimum granularity is minute (i.e Jobs can be scheduled to be executed
every minute)
2) Cron job can be scheduled by any normal user ( if not restricted by super
user )
3) Cron expects system to be running 24 x 7. If a job is scheduled, and
system is down during that time, job is not executed
4) Ideal for servers
5) Use cron when a job has to be executed at a particular hour and minute
Anacron :
1) Minimum granularity is only in days
2) Anacron can be used only by super user ( but there are workarounds to
make it usable by normal user )
3) Anacron doesn’t expect system to be running 24 x 7. If a job is scheduled,
and system is down during that time, it start the jobs when the system
comes back up.
4) Ideal for desktops and laptops
5) Use anacron when a job has to be executed irrespective of hour and
minute
30) Default Port numbers used by ssh,ftp,http,https,telnet,smtp,pop3,pop3s,imap,imaps
Ans SSH 22, ftp 20/21, http 80, https 443, SMTP/SMPTS 25/465, POP3/POP3S 110/995, IMAP/IMAPS 143/993
31) How to setup ACLs in following case:
1) Create a file FILE1 and this should be read,write,executable for all user but Read only for user USER1
2) Copy FILE1 ACLs to FILE2 ACL
3) Delete a USER1's rule for FILE1 which were setup in step 1)
Ans 1) touch FILE1 ; chmod 777 FILE1 ; setfacl -m u:USER1:r FILE1
2) getfacl FILE1 | setfacl --set-file=- FILE2
3) setfacl -x u:USER1 FILE1
32) How to make USB bootable?
Ans Write efidisk.img from RHEL 6 DVD images/ subdirectory to USB
dd if=efidisk.img of=/dev/usb (usb device name)
33) How can we check disk/device status/failure/errors using smartctl utility?
Ans Try following to check:
Enable/Disable SMART on device/disk : smartctl -s on /dev/sda
Check device SMART health : smartctl -H /dev/sda
Check device SMART capabilities : smartctl -c /dev/sda
Enable/Disable automatic offline testing on device : smartctl -o on/off /dev/sda
Show device SMART vendor-specific Attributes and values : smartctl -A /dev/sda
Show device log [TYPE : error, selftest, selective, directory,background,
scttemp[sts,hist]] : smartctl -l TYPE /dev/sda
Run test on device [TEST: offline short long conveyance select,M-N pending,N
afterselect,[on|off] scttempint,N[,p] : smartctl -t /dev/sda
34) What is the difference between ext2 vs ext3 vs ext4?
Ans http://www.thegeekstuff.com/2011/05/ext2-ext3-ext4/
35) Disable ping to avoid network/ICMP flood
Ans Set following in /etc/sysctl.conf : net.ipv4.icmp_echo_ignore_all = 1
Then "sysctl -p"
or
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
36) What is SYN Flood, ICMP Flood
Ans SYN Flood : A SYN flood occurs when a host sends a flood of TCP/SYN packets, often with a
fake/forged sender address. Each of these packets is handled like a connection request, causing the
server to spawn a half-open connection, by sending back a TCP/SYN-ACK packet(Acknowledge), and
waiting for a packet in response from the sender address(response to the ACK Packet). However,
because the sender address is forged, the response never comes. These half-open connections
saturate the number of available connections the server is able to make, keeping it from responding to
legitimate requests until after the attack ends
ICMP Flood : There are three types of ICMP Flood :
1) Smurf Attack : http://en.wikipedia.org/wiki/Smurf_attack
2) Ping Flood : http://en.wikipedia.org/wiki/Ping_flood
3) Ping of Death : http://en.wikipedia.org/wiki/Ping_of_death
37) What is the difference between Unix vs Linux Kernels?
Ans Please find below given link :
http://www.thegeekstuff.com/2012/01/linux-unix-kernel/
38) How to setup Password less remote login/ssh?
Ans Use "ssh-keygen -t dsa or rsa" at local system for creating public and private keys
Then copy /root/.ssh/id_dsa.pub to remote_server by name /root/.ssh/authorized_keys
Change permissions of /root/.ssh/authorized_keys file at remote_server "chmod 0600 ~/.ssh/authorized_keys"
Now try to login from local system to remote_server "ssh root@remote_server"
39) Command to see default kernel image file
Ans "grubby --default-kernel"
40) How to create lvm mirror
Ans lvcreate -L 50G -m1 -n LVMmirror vg0
41) Command to check last runlevel
Ans who -r
42) What do you mean by File System?
Ans File System is a method to store and organize files and directories on disk. A file system can have different formats called file system types. These formats determine how the information is stored as files and directories.
43) What is the requirement of udev daemon?
Ans Create and remove device nodes or files in /dev/ directory
44) What are block and character devices?
Ans Both the devices are present in /dev directory
Block device files talks to devices block by block [1 block at a time (1 block = 512 bytes to 32KB)].
Examples: - USB disk, CDROM, Hard Disk (sda, sdb, sdc etc....)
45) How to Convert ext2 to ext3 File System?
Ans tune2fs -j /dev/{device-name}
46) File required to modify for setting up kernel parameters permanent
Ans /etc/sysctl.conf
47) Commands used to install, list and remove modules from kernel
Ans Installing/adding a module:
insmod mod_name
modprobe mod_name
List installed modules : lsmod
Removing a module : modprobe -r mod_name
48) How to create swap using a file and delete swap
Ans Adding swap :
dd if=/dev/zero of=/opt/myswap bs=1024 count=4
mkswap /opt/myswap
swapon -a
For adding this myswap at boot time, add following in /etc/fstab file:
/opt/myswap swap swap defaults 0 0
Deleting Swap :
Run "swapoff /opt/myswap" command
Remove the entry from /etc/fstab file
Remove /opt/myswap file (using rm command)
49) What vmstat show
Ans vmstat (virtual memory statistics) is a computer system monitoring tool that collects and displays summary information about operating system memory, processes, interrupts, paging and block I/O
Screen : needs to be detached, should not be exited to access remotely/locally
Script : creates a file and store all the terminal output to this file
52) How can we check which process is assigned to which processor?
Ans Run "ps -elFL" and find out the PSR column which is showing the processor number to the process
53) How can we check vendor, version, release date, size, package information etc... of any installed rpm?
Ans) rpm -qi package-name , for example:
rpm -qi ypbind-1.19-12.el5
--------------------------------------------------------------------------------------------------------------------------------------------------------
Q: - How are devices represented in UNIX?
All devices are represented by files called special files that are located in /dev directory.
Q: - What is 'inode'?
All UNIX files have its description stored in a structure called 'inode'. The inode contains info about the file-size, its location, time of last access, time of last modification, permission and so on. Directories are also represented as files and have an associated inode.
Q: - What are the process states in Unix?
As a process executes it changes state according to its circumstances. Unix processes have the following states:
Running : The process is either running or it is ready to run .
Waiting : The process is waiting for an event or for a resource.
Stopped : The process has been stopped, usually by receiving a signal.
Zombie : The process is dead but have not been removed from the process table.
Q: - What command should you use to check the number of files and disk space used and each user's defined quotas?
repquota
Q: - What command is used to remove the password assigned to a group?
gpasswd -r
Q: - What can you type at a command line to determine which shell you are using?
echo $SHELL
Q: - Write a command to find all of the files which have been accessed within the last 30 days.
find / -type f -atime -30 > filename.txt
Q: - What is a zombie?
Zombie is a process state when the child dies before the parent process. In this case the structural information of the process is still in the process table.
Q: - What daemon is responsible for tracking events on your system?
syslogd
Q: - What do you mean a File System?
File System is a method to store and organize files and directories on disk. A file system can have different formats called file system types. These formats determine how the information is stored as files and directories.
Q: - Tell me the name of directory structure hierarchy for Linux
/root
/boot
/bin
/sbin
/proc
/mnt
/usr
/var
/lib
/etc
/dev
/opt
/srv
/tmp
/media
Q: - What does /boot directory contains?
The /boot/ directory contains static files required to boot the system, such as the Linux kernel, boot loader configuration files. These files are essential for the system to boot properly.
Q: - If some one deletes /boot directory from your server, than what will happen?
In that case your server will be in unbootable state. Your Server can’t boot without /boot directory because this directory contains all bootable files
Q: - What does /dev directory contain?
The /dev directory contains all device files that are attached to system or virtual device files that are provided by the kernel.
Q: - What is the role of udev daemon?
The udev demon used to create and remove all these device nodes or files in /dev/ directory.
Q: - What kind of files or nodes /dev/ directory contains and how do I access or see device files?
Block Device Files:-
Block device files talks to devices block by block [1 block at a time (1 block = 512 bytes to 32KB)].
Examples: - USB disk, CDROM, Hard Disk
# ls /dev/sd*
brw-rw---- 1 root root 8, 0 Mar 15 2009 sda
brw-rw---- 1 root root 8, 1 Mar 15 2009 sda1
brw-rw---- 1 root root 8, 2 Mar 15 2009 sda2
brw-rw---- 1 root root 8, 3 Mar 15 2009 sda3
brw-rw---- 1 root root 8, 4 Mar 15 2009 sda4
brw-rw---- 1 root root 8, 16 Mar 15 2009 sdb
Character Device Files:-
Character device files talk to devices character by character.
Examples: - Virtual terminals, terminals, serial modems, random numbers
#ls /dev/tty*
crw-rw---- 1 root root 4, 64 Mar 15 2009 ttyS0
crw-rw---- 1 root root 4, 65 Mar 15 2009 ttyS1
crw-rw---- 1 root root 4, 66 Mar 15 2009 ttyS2
crw-rw---- 1 root root 4, 67 Mar 15 2009 ttyS3
Q: - Tell me the name of device file for PS/2 mouse connection.
/dev/psaux
Q: - Tell me the name of device file for parallel port (Printers).
/dev/lp0
Q: - What does /etc/X11/ directory contains?
The /etc/X11/ directory is for X Window System configuration files, such as xorg.conf.
Q: - What does /etc/skell directory contains?
The /etc/skel directory contains files and directories that are automatically copied over to a new user's home directory when such user is created by the useradd or adduser command.
Q: - Tell me name of Linux File systems?
Ext2
Ext3
---------------------------------------------------------------------------------------------------------------------------------------------------------
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.
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
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
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
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
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)
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
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
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.
# 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
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
PART 3: LINUX Interview Questions
In part 3 we are going to see the below questions and answers.
13. What is swap ? Why we need swap partition?
14. How to Create / extend / remove swap partition?
15. Why does kernel need IO scheduler?
16. How to view Current Disk i/o scheduler ? How to change I/o Scheduler for hard disk?
17: How to restore the default system permission on Linux ?
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full,
inactive pages in memory are moved to the swap space.
Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.
A.Create a SWAP Partition:
1. Create a file system on disk
#fdisk /dev/cciss/c?d?
Note : Make the new partition as swap. Change toggle id to 82 (for swap).
2. Make the FS as Swap partition
#mkswap /dev/cciss/c?d?p?
3. Run swapon commad to enable swap space
#swapon /dev/cciss/c?d?p?
4.Verify the new swap partition
#cat /proc/swap
or
#swapon -s
5. Add this new swap partion entry to /etc/fstab
vi /etc/fstab
/dev/cciss/c?d?p? swap swap defaults 0 0
B.How to increase / extend SWAP partition ?
Follow the below steps to increase the Swap for LVM
# swapoff -v /dev/rootvg/swapvol
# lvm lvresize /dev/rootvg/swapvol -L +8G or lvextend -L +8G /dev/rootvg/swapvol
# mkswap /dev/rootvg/swapvol
# swapon -va
C.How to remove the swap partition ?
1.swapoff -v /dev/VolGroup00/swap_vol
2.lvremove /dev/VolGroup00/swap_vol
3. Remove the entry from /etc/fstab
Without an I/O scheduler, the kernel would basically just issue each request to disk in the order that it received them. This could result in massive HardDisk
thrashing: if one process was reading from one part of the disk, and one writing to another, the heads would have to seek back and forth across the disk for
every operation. The scheduler’s main goal is to optimise disk access times.
Assuming that we have a disk name /dev/sda, type :
# cat /sys/block/{DEVICE-NAME}/queue/scheduler
# cat /sys/block/sda/queue/scheduler
How to set I/O Scheduler For A Hard Disk ?
To set a specific scheduler, simply type the command as follows:
# echo {SCHEDULER-NAME} > /sys/block/{DEVICE-NAME}/queue/scheduler
For example, set noop scheduler, enter:
# echo noop > /sys/block/hda/queue/scheduler
OR
Edit /boot/grub/grub.conf and enter in kernel line "elevator=noop" or any other scheduler available.
There are currently 4 available IO schedulers :
* No-op Scheduler
* Anticipatory IO Scheduler (AS)
* Deadline Scheduler
* Complete Fair Queueing Scheduler (CFQ)
Changing Scheduler:
The most reliable way to change schedulers is to set the kernel option “elevator” at boot time. You can set it to one of “as”, “cfq”, “deadline” or “noop”, to set the appropriate scheduler.
elevator=cfq
We can recover or restore the defualt file / folder permission and ownership using rpm command with the options -setperms and --setugids.
This is very usefull option which i found in RPM command.
1) To reset uids and gids on files and directories :
# for i in $(rpm -qa); do rpm --setugids $i; done
2) To permissions on files and directories
#for i in $(rpm -qa); do rpm --setperms $i; done
The below Questions will help for basic shell scripting interview.
1. Construct pipes to execute the following jobs.
1. Output of who should be displayed on the screen with value of total number of users who have logged in
displayed at the bottom of the list.
2. Output of ls should be displayed on the screen and from this output the lines containing the word ‘poem’
should be counted and the count should be stored in a file.
3. Contents of file1 and file2 should be displayed on the screen and this output should be appended in a file
.
From output of ls the lines containing ‘poem’ should be displayed on the screen along with the count.
4. Name of cities should be accepted from the keyboard . This list should be combined with the list present
in a file. This combined list should be sorted and the sorted list should be stored in a file ‘newcity’.
5. All files present in a directory dir1 should be deleted any error while deleting should be stored in a file
‘errorlog’.
2. Explain the following commands.
$ ls > file1
$ banner hi-fi > message
$ cat par.3 par.4 par.5 >> report
$ cat file1>file1
$ date ; who
$ date ; who > logfile
$ (date ; who) > logfile
3. What is the significance of the “tee” command?
It reads the standard input and sends it to the standard output while redirecting a copy of what it has read to
the file specified by the user.
4. What does the command “ $who | sort –logfile > newfile” do?
The input from a pipe can be combined with the input from a file . The trick is to use the special symbol “-“
(a hyphen) for those commands that recognize the hyphen as std input.
In the above command the output from who becomes the std input to sort , meanwhile sort opens the file
logfile, the contents of this file is sorted together with the output of who (rep by the hyphen) and the sorted
output is redirected to the file newfile.
5. What does the command “$ls | wc –l > file1” do?
ls becomes the input to wc which counts the number of lines it receives as input and instead of displaying
this count , the value is stored in file1.
6. Which of the following commands is not a filter man , (b) cat , (c) pg , (d) head
Ans: man
A filter is a program which can receive a flow of data from std input, process (or filter) it and send the result
to the std output.
7. How is the command “$cat file2 “ different from “$cat >file2 and >> redirection operators ?
is the output redirection operator when used it overwrites while >> operator appends into the file.
8.What difference between cmp and diff commands?
cmp - Compares two files byte by byte and displays the first mismatch
diff - tells the changes to be made to make the files identical
9.Write a command to kill the last background job?
Kill $!
10. Explain the steps that a shell follows while processing a command.
After the command line is terminated by the key, the shel goes ahead with processing the command line in
one or more passes. The sequence is well defined and assumes the following order.
Parsing: The shell first breaks up the command line into words, using spaces and the delimiters, unless
quoted. All consecutive occurrences of a space or tab are replaced here with a single space.
Variable evaluation: All words preceded by a $ are avaluated as variables, unless quoted or escaped.
Command substitution: Any command surrounded by backquotes is executed by the shell which then
replaces the standard output of the command into the command line.
Wild-card interpretation: The shell finally scans the command line for wild-cards (the characters *, ?, [, ]).
Any word containing a wild-card is replaced by a sorted list of
filenames that match the pattern. The list of these filenames then forms the arguments to the command.
PATH evaluation: It finally looks for the PATH variable to determine the sequence of directories it has to
search in order to hunt for the command.
11.Write a command to display a file’s contents in various formats?
Answer :
$od -cbd file_name
12. What will the following command do?
$ echo *
Ans : It is similar to 'ls' command and displays all the files in the current directory
13.What is the use of the command "ls -x chapter[1-5]"
ls stands for list; so it displays the list of the files that starts with 'chapter' with suffix '1' to '5', chapter1,
chapter2, and so on.
c - character, b - binary (octal), d-decimal, od=Octal Dump.
14. How does the kernel differentiate device files and ordinary files?
Answer : Kernel checks 'type' field in the file's inode structure.
15. What are shell variables?
Shell variables are special variables, a name-value pair created and maintained by the shell.
16.How to terminate a process which is running and the specialty on command kill 0?
Answer :
With the help of kill command we can terminate the process.
Syntax: kill pid
Kill 0 - kills all processes in your system except the login shell.
Example: PATH, HOME, MAIL and TERM
1.What are Daemons ??
Daemons are services that provide several functions that may not be available under the base operating system.
Its main task is to listen for service request and at the same time to act on these requests. After the service is done,
it is then disconnected and waits for further requests.
2.What are environmental variables?
Environmental variables are global settings that control the shell’s function as well as that of other Linux programs.
Another common term for environmental variables is global shell variables
3.What are the different modes when using vi editor?
There are 3 modes under vi:
- Command mode – this is the mode where you start in
- Edit mode – this is the mode that allows you to do text editing
- Ex mode – this is the mode wherein you interact with vi with instructions to process a file
4.How can we change speed and make full duplex settings for eth0
Ans We can do this with below given 2 methods:
ethtool -s eth0 speed 100 duplex full
ethtool -s eth0 speed 10 duplex half
OR
mii-tool -F 100baseTx-HD
mii-tool -F 10baseT-HD
5.What are the process states in Unix?
As a process executes it changes state according to its circumstances. Unix processes have the following states:
Running : The process is either running or it is ready to run .
Waiting : The process is waiting for an event or for a resource.
Stopped : The process has been stopped, usually by receiving a signal.
Zombie : The process is dead but have not been removed from the process table.
6.Explain /proc filesystem?
/proc is a virtual filesystem that provides detailed information about Linux kernel, hardware’s and running processes. Files under /proc directory named as Virtual files.
Because /proc contains virtual files that’s why it is called 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, like the /proc/filesystems file and the /proc/sys/ directory provide system configuration information and interfaces.
7.What is the difference between hardware RAID and Software RAID?
The hardware-based RAID is independent from the host. A Hardware RAID device connects to the SCSI controller and presents the RAID arrays as a single SCSI drive.
An external RAID system moves all RAID handling "intelligence" into a controller located in the external disk subsystem. The whole subsystem is connected to the host via a normal SCSI controller and appears to the host as a single disk.
Software RAID is implemented under OS Kernel level. The Linux kernel contains an MD driver that allows the RAID solution to be completely hardware independent.
The performance of a software-based array depends on the server CPU performance and load.
8.What is the difference between cron and anacron
Ans Cron :
1) Minimum granularity is minute (i.e Jobs can be scheduled to be executed
every minute)
2) Cron job can be scheduled by any normal user ( if not restricted by super
user )
3) Cron expects system to be running 24 x 7. If a job is scheduled, and
system is down during that time, job is not executed
4) Ideal for servers
5) Use cron when a job has to be executed at a particular hour and minute
Anacron :
1) Minimum granularity is only in days
2) Anacron can be used only by super user ( but there are workarounds to
make it usable by normal user )
3) Anacron doesn’t expect system to be running 24 x 7. If a job is scheduled,
and system is down during that time, it start the jobs when the system
comes back up.
4) Ideal for desktops and laptops
5) Use anacron when a job has to be executed irrespective of hour and
minute
9.What is CUPS?
CUPS stands for "Common UNIX Printing System". CUPS is a open source printing system developed by Apple Inc. CUPS uses the Internet Printing Protocol (IPP) to allow local printing and print sharing.
The log files for the CUPS printing system are located in the /var/log/cups/ directory.
10.How Many Run Levels present in Linux?
There are 7 run levels, with each having its own properties.
- 0: Halt the system
- 1: Single-user mode
- 2: Not used
- 3: Multi-user mode with text login
- 4: Not used
- 5: Multi-user mode with graphical login
- 6: Reboot
Ans GNU GRUB is a Multiboot boot loader. It was derived from GRUB, the GRand Unified Bootloader,
which was originally designed and implemented by Erich Stefan Boleyn.
Briefly, a boot loader is the first software program that runs when a computer starts. It is
responsible for loading and transferring control to the operating system kernel software
(such as the Hurd or Linux). The kernel, in turn, initializes the rest of the operating
system (e.g. GNU)
2) Explain Linux Boot Process
Ans http://www.thegeekstuff.com/2011/02/linux-boot-process/
3) Which files are called for user profile by default when a user gets login
Ans $HOME/.bash_profile, $HOME/.bash_bashrc
4) Which file needs to update if srequired to change default runlevel 5 to 3
Ans File is /etc/inittab and required to change below lines:
id:5:initdefault: to id:3:initdefault:
5) What command used for showing user info like Login Name, Canonical Name, Home Directory,Shell etc..
Ans FINGER command can be used i.g; finger username
6) What is inode number
Ans 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
iNode number also called as index number, it consists following attributes:
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)
File deletion time
Number of links (soft/hard)
Extended attribute such as append only or no one can delete file including root user
(immutability)
Access Control List (ACLs)
Following command will be used to show inodes of file and folders:
ls -i
Following command will show complete info about any file or folders with inode number
stat file/folder
Files/Folders can also be deleted using inode numbers with following command:
find out the inode number using 'ls -il' command then run below command
find . -inum inode_number -exec rm -i {} \;
7) How can we increase disk read performance in single command
Ans blockdev command
This is sample output - yours may be different.
# Before test
$ blockdev --getra /dev/sdb
256
$ time dd if=/tmp/disk.iso of=/dev/null bs=256k
2549+1 records in
2549+1 records out
668360704 bytes (668 MB) copied, 6,84256 seconds, 97,7 MB/s
real 0m6.845s
user 0m0.004s
sys 0m0.865s
# After test
$ blockdev --setra 1024 /dev/sdb
$ time dd if=/tmp/disk.iso of=/dev/null bs=256k
2435+1 records in
2435+1 records out
638390272 bytes (638 MB) copied, 0,364251 seconds, 1,8 GB/s
real 0m0.370s
user 0m0.001s
sys 0m0.370s
8) .... command to change user password expiration time
Ans CHAGE
9) Command used to lock user password
Ans usermod -L username
10) How many default number of Shells available and what are their names?
Ans SH, BASH, CSH, TCSH, NOLOGIN, KSH
11) Which file defines the attributes like UID, PASSWORD expiry, HOME Dir create or not while
adding user
Ans /etc/login.defs
12) ...... command used for changing authentication of linux system to LDAP/NIS/SMB/KERBOS
Ans authconfig
13) ...... command used for changing the attributes of any file
Ans chattr
14) What is the path of network (ethX) configuration files
Ans /etc/sysconfig/network-scripts/ethX
15) How can we change speed and make full duplex settings for eth0
Ans We can do this with below given 2 methods:
ethtool -s eth0 speed 100 duplex full
ethtool -s eth0 speed 10 duplex half
OR
mii-tool -F 100baseTx-HD
mii-tool -F 10baseT-HD
16) File which stores the DNS configuration at client side
Ans /etc/resolve.conf
17) Main configuration file and command used for exporting NFS directories and it's deamons
Ans /etc/exports and exportfs -av , deamons are quotad, portmapper, mountd, nfsd and nlockmgr/status
18) What is command to check ports running/used over local machine
Ans netstat -antp
19) What is the command to check open ports at remote machine
Ans nmap
20) What is the difference between soft and hard links
Ans Soft Links => 1) Soft link files will have different inode numbers then source file
2) If original file deleted then soft link file be of no use
3) Soft links are not updated
4) Can create links between directories
5) Can cross file system boundaries
Hard Links => 1) Hard links will have the same inode number as source file
2) Hard links can not link directories
3) Can not cross file system boundaries
4) Hard links always refers to the source, even if moved or removed
21) How to setup never expired user password
Ans chage -E never username
22) Restricting insertion into file if full permission are assigned to all
Ans chattr +i filename
23) Display or Kill all processes which are accessing any folder/file
Ans Display User who are using file/folder : fuser -u file/folder
Kill All Processes which are using file/folder: fuser -k file/folder
24) Kill any user's all processes
Ans killall -u username
25) How can we have daily system analysis and reports over mail
Ans Use logwatch
26) How can we rotate logs using logrotate without performing any operation like move and gzip'ng over original file and then creating new file (which is very lengthy process)
Ans We can use "logrotate"'s "copytruncate" option which will simply copy original file and
truncate original file :)
27) Command to collect detailed information about the hardware and setup of your system
Ans dmidecode , sysreport
28) Command to check PCI devices vendor or version
Ans lspci
29) What is the difference between cron and anacron
Ans Cron :
1) Minimum granularity is minute (i.e Jobs can be scheduled to be executed
every minute)
2) Cron job can be scheduled by any normal user ( if not restricted by super
user )
3) Cron expects system to be running 24 x 7. If a job is scheduled, and
system is down during that time, job is not executed
4) Ideal for servers
5) Use cron when a job has to be executed at a particular hour and minute
Anacron :
1) Minimum granularity is only in days
2) Anacron can be used only by super user ( but there are workarounds to
make it usable by normal user )
3) Anacron doesn’t expect system to be running 24 x 7. If a job is scheduled,
and system is down during that time, it start the jobs when the system
comes back up.
4) Ideal for desktops and laptops
5) Use anacron when a job has to be executed irrespective of hour and
minute
30) Default Port numbers used by ssh,ftp,http,https,telnet,smtp,pop3,pop3s,imap,imaps
Ans SSH 22, ftp 20/21, http 80, https 443, SMTP/SMPTS 25/465, POP3/POP3S 110/995, IMAP/IMAPS 143/993
31) How to setup ACLs in following case:
1) Create a file FILE1 and this should be read,write,executable for all user but Read only for user USER1
2) Copy FILE1 ACLs to FILE2 ACL
3) Delete a USER1's rule for FILE1 which were setup in step 1)
Ans 1) touch FILE1 ; chmod 777 FILE1 ; setfacl -m u:USER1:r FILE1
2) getfacl FILE1 | setfacl --set-file=- FILE2
3) setfacl -x u:USER1 FILE1
32) How to make USB bootable?
Ans Write efidisk.img from RHEL 6 DVD images/ subdirectory to USB
dd if=efidisk.img of=/dev/usb (usb device name)
33) How can we check disk/device status/failure/errors using smartctl utility?
Ans Try following to check:
Enable/Disable SMART on device/disk : smartctl -s on /dev/sda
Check device SMART health : smartctl -H /dev/sda
Check device SMART capabilities : smartctl -c /dev/sda
Enable/Disable automatic offline testing on device : smartctl -o on/off /dev/sda
Show device SMART vendor-specific Attributes and values : smartctl -A /dev/sda
Show device log [TYPE : error, selftest, selective, directory,background,
scttemp[sts,hist]] : smartctl -l TYPE /dev/sda
Run test on device [TEST: offline short long conveyance select,M-N pending,N
afterselect,[on|off] scttempint,N[,p] : smartctl -t /dev/sda
34) What is the difference between ext2 vs ext3 vs ext4?
Ans http://www.thegeekstuff.com/2011/05/ext2-ext3-ext4/
35) Disable ping to avoid network/ICMP flood
Ans Set following in /etc/sysctl.conf : net.ipv4.icmp_echo_ignore_all = 1
Then "sysctl -p"
or
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
36) What is SYN Flood, ICMP Flood
Ans SYN Flood : A SYN flood occurs when a host sends a flood of TCP/SYN packets, often with a
fake/forged sender address. Each of these packets is handled like a connection request, causing the
server to spawn a half-open connection, by sending back a TCP/SYN-ACK packet(Acknowledge), and
waiting for a packet in response from the sender address(response to the ACK Packet). However,
because the sender address is forged, the response never comes. These half-open connections
saturate the number of available connections the server is able to make, keeping it from responding to
legitimate requests until after the attack ends
ICMP Flood : There are three types of ICMP Flood :
1) Smurf Attack : http://en.wikipedia.org/wiki/Smurf_attack
2) Ping Flood : http://en.wikipedia.org/wiki/Ping_flood
3) Ping of Death : http://en.wikipedia.org/wiki/Ping_of_death
37) What is the difference between Unix vs Linux Kernels?
Ans Please find below given link :
http://www.thegeekstuff.com/2012/01/linux-unix-kernel/
38) How to setup Password less remote login/ssh?
Ans Use "ssh-keygen -t dsa or rsa" at local system for creating public and private keys
Then copy /root/.ssh/id_dsa.pub to remote_server by name /root/.ssh/authorized_keys
Change permissions of /root/.ssh/authorized_keys file at remote_server "chmod 0600 ~/.ssh/authorized_keys"
Now try to login from local system to remote_server "ssh root@remote_server"
39) Command to see default kernel image file
Ans "grubby --default-kernel"
40) How to create lvm mirror
Ans lvcreate -L 50G -m1 -n LVMmirror vg0
41) Command to check last runlevel
Ans who -r
42) What do you mean by File System?
Ans File System is a method to store and organize files and directories on disk. A file system can have different formats called file system types. These formats determine how the information is stored as files and directories.
43) What is the requirement of udev daemon?
Ans Create and remove device nodes or files in /dev/ directory
44) What are block and character devices?
Ans Both the devices are present in /dev directory
Block device files talks to devices block by block [1 block at a time (1 block = 512 bytes to 32KB)].
Examples: - USB disk, CDROM, Hard Disk (sda, sdb, sdc etc....)
Character device files talk to devices character by character.
Examples: - Virtual terminals, terminals, serial modems, random numbers (tty{0,1,2,3......})
Examples: - Virtual terminals, terminals, serial modems, random numbers (tty{0,1,2,3......})
45) How to Convert ext2 to ext3 File System?
46) File required to modify for setting up kernel parameters permanent
Ans /etc/sysctl.conf
47) Commands used to install, list and remove modules from kernel
Ans Installing/adding a module:
insmod mod_name
modprobe mod_name
List installed modules : lsmod
Removing a module : modprobe -r mod_name
48) How to create swap using a file and delete swap
Ans Adding swap :
dd if=/dev/zero of=/opt/myswap bs=1024 count=4
mkswap /opt/myswap
swapon -a
For adding this myswap at boot time, add following in /etc/fstab file:
/opt/myswap swap swap defaults 0 0
Deleting Swap :
Run "swapoff /opt/myswap" command
Remove the entry from /etc/fstab file
Remove /opt/myswap file (using rm command)
49) What vmstat show
Ans vmstat (virtual memory statistics) is a computer system monitoring tool that collects and displays summary information about operating system memory, processes, interrupts, paging and block I/O
50) What is tmpfs File System
Ans Reference : http://en.wikipedia.org/wiki/Tmpfs
tmpfs is a common name for a temporary file storage facility on many Unix-like operating systems. It is intended to appear as a mounted file system, but stored in volatile memory instead of a persistent storage device. A similar construction is a RAM disk, which appears as a virtual disk drive and hosts a disk file system.
Everything stored in tmpfs is temporary in the sense that no files will be created on the hard drive; however, swap space is used as backing store in case of low memory situations. On reboot, everything in tmpfs will be lost.
The memory used by tmpfs grows and shrinks to accommodate the files it contains and can be swapped out to swap space.
51) What is the difference between screen and script commands?
Ans Screen is an screen manager with VT100/ANSI terminal emulation and used to take GNU screen session remotely or locally and while Scriptmake typescript of terminal sessionScreen : needs to be detached, should not be exited to access remotely/locally
Script : creates a file and store all the terminal output to this file
52) How can we check which process is assigned to which processor?
Ans Run "ps -elFL" and find out the PSR column which is showing the processor number to the process
53) How can we check vendor, version, release date, size, package information etc... of any installed rpm?
Ans) rpm -qi package-name , for example:
rpm -qi ypbind-1.19-12.el5
--------------------------------------------------------------------------------------------------------------------------------------------------------
Q: - How are devices represented in UNIX?
All devices are represented by files called special files that are located in /dev directory.
Q: - What is 'inode'?
All UNIX files have its description stored in a structure called 'inode'. The inode contains info about the file-size, its location, time of last access, time of last modification, permission and so on. Directories are also represented as files and have an associated inode.
Q: - What are the process states in Unix?
As a process executes it changes state according to its circumstances. Unix processes have the following states:
Running : The process is either running or it is ready to run .
Waiting : The process is waiting for an event or for a resource.
Stopped : The process has been stopped, usually by receiving a signal.
Zombie : The process is dead but have not been removed from the process table.
Q: - What command should you use to check the number of files and disk space used and each user's defined quotas?
repquota
Q: - What command is used to remove the password assigned to a group?
gpasswd -r
Q: - What can you type at a command line to determine which shell you are using?
echo $SHELL
Q: - Write a command to find all of the files which have been accessed within the last 30 days.
find / -type f -atime -30 > filename.txt
Q: - What is a zombie?
Zombie is a process state when the child dies before the parent process. In this case the structural information of the process is still in the process table.
Q: - What daemon is responsible for tracking events on your system?
syslogd
Q: - What do you mean a File System?
File System is a method to store and organize files and directories on disk. A file system can have different formats called file system types. These formats determine how the information is stored as files and directories.
Q: - Tell me the name of directory structure hierarchy for Linux
/root
/boot
/bin
/sbin
/proc
/mnt
/usr
/var
/lib
/etc
/dev
/opt
/srv
/tmp
/media
Q: - What does /boot directory contains?
The /boot/ directory contains static files required to boot the system, such as the Linux kernel, boot loader configuration files. These files are essential for the system to boot properly.
Q: - If some one deletes /boot directory from your server, than what will happen?
In that case your server will be in unbootable state. Your Server can’t boot without /boot directory because this directory contains all bootable files
Q: - What does /dev directory contain?
The /dev directory contains all device files that are attached to system or virtual device files that are provided by the kernel.
Q: - What is the role of udev daemon?
The udev demon used to create and remove all these device nodes or files in /dev/ directory.
Q: - What kind of files or nodes /dev/ directory contains and how do I access or see device files?
Block Device Files:-
Block device files talks to devices block by block [1 block at a time (1 block = 512 bytes to 32KB)].
Examples: - USB disk, CDROM, Hard Disk
# ls /dev/sd*
brw-rw---- 1 root root 8, 0 Mar 15 2009 sda
brw-rw---- 1 root root 8, 1 Mar 15 2009 sda1
brw-rw---- 1 root root 8, 2 Mar 15 2009 sda2
brw-rw---- 1 root root 8, 3 Mar 15 2009 sda3
brw-rw---- 1 root root 8, 4 Mar 15 2009 sda4
brw-rw---- 1 root root 8, 16 Mar 15 2009 sdb
Character Device Files:-
Character device files talk to devices character by character.
Examples: - Virtual terminals, terminals, serial modems, random numbers
#ls /dev/tty*
crw-rw---- 1 root root 4, 64 Mar 15 2009 ttyS0
crw-rw---- 1 root root 4, 65 Mar 15 2009 ttyS1
crw-rw---- 1 root root 4, 66 Mar 15 2009 ttyS2
crw-rw---- 1 root root 4, 67 Mar 15 2009 ttyS3
Q: - Tell me the name of device file for PS/2 mouse connection.
/dev/psaux
Q: - Tell me the name of device file for parallel port (Printers).
/dev/lp0
Q: - What does /etc/X11/ directory contains?
The /etc/X11/ directory is for X Window System configuration files, such as xorg.conf.
Q: - What does /etc/skell directory contains?
The /etc/skel directory contains files and directories that are automatically copied over to a new user's home directory when such user is created by the useradd or adduser command.
Q: - Tell me name of Linux File systems?
Ext2
Ext3
---------------------------------------------------------------------------------------------------------------------------------------------------------
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
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
PART 3: LINUX Interview Questions
In part 3 we are going to see the below questions and answers.
13. What is swap ? Why we need swap partition?
14. How to Create / extend / remove swap partition?
15. Why does kernel need IO scheduler?
16. How to view Current Disk i/o scheduler ? How to change I/o Scheduler for hard disk?
17: How to restore the default system permission on Linux ?
13. What is swap ? Why we need swap partition?
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full,
inactive pages in memory are moved to the swap space.
Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.
14. How to Create / extend / remove swap partition?
A.Create a SWAP Partition:
1. Create a file system on disk
#fdisk /dev/cciss/c?d?
Note : Make the new partition as swap. Change toggle id to 82 (for swap).
2. Make the FS as Swap partition
#mkswap /dev/cciss/c?d?p?
3. Run swapon commad to enable swap space
#swapon /dev/cciss/c?d?p?
4.Verify the new swap partition
#cat /proc/swap
or
#swapon -s
5. Add this new swap partion entry to /etc/fstab
vi /etc/fstab
/dev/cciss/c?d?p? swap swap defaults 0 0
B.How to increase / extend SWAP partition ?
Follow the below steps to increase the Swap for LVM
# swapoff -v /dev/rootvg/swapvol
# lvm lvresize /dev/rootvg/swapvol -L +8G or lvextend -L +8G /dev/rootvg/swapvol
# mkswap /dev/rootvg/swapvol
# swapon -va
C.How to remove the swap partition ?
1.swapoff -v /dev/VolGroup00/swap_vol
2.lvremove /dev/VolGroup00/swap_vol
3. Remove the entry from /etc/fstab
15. Why does kernel need IO scheduler?
Without an I/O scheduler, the kernel would basically just issue each request to disk in the order that it received them. This could result in massive HardDisk
thrashing: if one process was reading from one part of the disk, and one writing to another, the heads would have to seek back and forth across the disk for
every operation. The scheduler’s main goal is to optimise disk access times.
16. How to view Current Disk i/o scheduler ? How to change I/o Scheduler for hard disk?
Assuming that we have a disk name /dev/sda, type :
# cat /sys/block/{DEVICE-NAME}/queue/scheduler
# cat /sys/block/sda/queue/scheduler
How to set I/O Scheduler For A Hard Disk ?
To set a specific scheduler, simply type the command as follows:
# echo {SCHEDULER-NAME} > /sys/block/{DEVICE-NAME}/queue/scheduler
For example, set noop scheduler, enter:
# echo noop > /sys/block/hda/queue/scheduler
OR
Edit /boot/grub/grub.conf and enter in kernel line "elevator=noop" or any other scheduler available.
There are currently 4 available IO schedulers :
* No-op Scheduler
* Anticipatory IO Scheduler (AS)
* Deadline Scheduler
* Complete Fair Queueing Scheduler (CFQ)
Changing Scheduler:
The most reliable way to change schedulers is to set the kernel option “elevator” at boot time. You can set it to one of “as”, “cfq”, “deadline” or “noop”, to set the appropriate scheduler.
elevator=cfq
17. How to restore the default system permission on Linux ?
We can recover or restore the defualt file / folder permission and ownership using rpm command with the options -setperms and --setugids.
This is very usefull option which i found in RPM command.
1) To reset uids and gids on files and directories :
# for i in $(rpm -qa); do rpm --setugids $i; done
2) To permissions on files and directories
#for i in $(rpm -qa); do rpm --setperms $i; done
Interview Questions : Shell Script Basic: PART 5
The below Questions will help for basic shell scripting interview.
1. Construct pipes to execute the following jobs.
1. Output of who should be displayed on the screen with value of total number of users who have logged in
displayed at the bottom of the list.
2. Output of ls should be displayed on the screen and from this output the lines containing the word ‘poem’
should be counted and the count should be stored in a file.
3. Contents of file1 and file2 should be displayed on the screen and this output should be appended in a file
.
From output of ls the lines containing ‘poem’ should be displayed on the screen along with the count.
4. Name of cities should be accepted from the keyboard . This list should be combined with the list present
in a file. This combined list should be sorted and the sorted list should be stored in a file ‘newcity’.
5. All files present in a directory dir1 should be deleted any error while deleting should be stored in a file
‘errorlog’.
2. Explain the following commands.
$ ls > file1
$ banner hi-fi > message
$ cat par.3 par.4 par.5 >> report
$ cat file1>file1
$ date ; who
$ date ; who > logfile
$ (date ; who) > logfile
3. What is the significance of the “tee” command?
It reads the standard input and sends it to the standard output while redirecting a copy of what it has read to
the file specified by the user.
4. What does the command “ $who | sort –logfile > newfile” do?
The input from a pipe can be combined with the input from a file . The trick is to use the special symbol “-“
(a hyphen) for those commands that recognize the hyphen as std input.
In the above command the output from who becomes the std input to sort , meanwhile sort opens the file
logfile, the contents of this file is sorted together with the output of who (rep by the hyphen) and the sorted
output is redirected to the file newfile.
5. What does the command “$ls | wc –l > file1” do?
ls becomes the input to wc which counts the number of lines it receives as input and instead of displaying
this count , the value is stored in file1.
6. Which of the following commands is not a filter man , (b) cat , (c) pg , (d) head
Ans: man
A filter is a program which can receive a flow of data from std input, process (or filter) it and send the result
to the std output.
7. How is the command “$cat file2 “ different from “$cat >file2 and >> redirection operators ?
is the output redirection operator when used it overwrites while >> operator appends into the file.
8.What difference between cmp and diff commands?
cmp - Compares two files byte by byte and displays the first mismatch
diff - tells the changes to be made to make the files identical
9.Write a command to kill the last background job?
Kill $!
10. Explain the steps that a shell follows while processing a command.
After the command line is terminated by the key, the shel goes ahead with processing the command line in
one or more passes. The sequence is well defined and assumes the following order.
Parsing: The shell first breaks up the command line into words, using spaces and the delimiters, unless
quoted. All consecutive occurrences of a space or tab are replaced here with a single space.
Variable evaluation: All words preceded by a $ are avaluated as variables, unless quoted or escaped.
Command substitution: Any command surrounded by backquotes is executed by the shell which then
replaces the standard output of the command into the command line.
Wild-card interpretation: The shell finally scans the command line for wild-cards (the characters *, ?, [, ]).
Any word containing a wild-card is replaced by a sorted list of
filenames that match the pattern. The list of these filenames then forms the arguments to the command.
PATH evaluation: It finally looks for the PATH variable to determine the sequence of directories it has to
search in order to hunt for the command.
11.Write a command to display a file’s contents in various formats?
Answer :
$od -cbd file_name
12. What will the following command do?
$ echo *
Ans : It is similar to 'ls' command and displays all the files in the current directory
13.What is the use of the command "ls -x chapter[1-5]"
ls stands for list; so it displays the list of the files that starts with 'chapter' with suffix '1' to '5', chapter1,
chapter2, and so on.
c - character, b - binary (octal), d-decimal, od=Octal Dump.
14. How does the kernel differentiate device files and ordinary files?
Answer : Kernel checks 'type' field in the file's inode structure.
15. What are shell variables?
Shell variables are special variables, a name-value pair created and maintained by the shell.
16.How to terminate a process which is running and the specialty on command kill 0?
Answer :
With the help of kill command we can terminate the process.
Syntax: kill pid
Kill 0 - kills all processes in your system except the login shell.
Example: PATH, HOME, MAIL and TERM
Linux Interview Questions - Part 6
1.What are Daemons ??
Daemons are services that provide several functions that may not be available under the base operating system.
Its main task is to listen for service request and at the same time to act on these requests. After the service is done,
it is then disconnected and waits for further requests.
2.What are environmental variables?
Environmental variables are global settings that control the shell’s function as well as that of other Linux programs.
Another common term for environmental variables is global shell variables
3.What are the different modes when using vi editor?
There are 3 modes under vi:
- Command mode – this is the mode where you start in
- Edit mode – this is the mode that allows you to do text editing
- Ex mode – this is the mode wherein you interact with vi with instructions to process a file
4.How can we change speed and make full duplex settings for eth0
Ans We can do this with below given 2 methods:
ethtool -s eth0 speed 100 duplex full
ethtool -s eth0 speed 10 duplex half
OR
mii-tool -F 100baseTx-HD
mii-tool -F 10baseT-HD
5.What are the process states in Unix?
As a process executes it changes state according to its circumstances. Unix processes have the following states:
Running : The process is either running or it is ready to run .
Waiting : The process is waiting for an event or for a resource.
Stopped : The process has been stopped, usually by receiving a signal.
Zombie : The process is dead but have not been removed from the process table.
6.Explain /proc filesystem?
/proc is a virtual filesystem that provides detailed information about Linux kernel, hardware’s and running processes. Files under /proc directory named as Virtual files.
Because /proc contains virtual files that’s why it is called 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, like the /proc/filesystems file and the /proc/sys/ directory provide system configuration information and interfaces.
7.What is the difference between hardware RAID and Software RAID?
The hardware-based RAID is independent from the host. A Hardware RAID device connects to the SCSI controller and presents the RAID arrays as a single SCSI drive.
An external RAID system moves all RAID handling "intelligence" into a controller located in the external disk subsystem. The whole subsystem is connected to the host via a normal SCSI controller and appears to the host as a single disk.
Software RAID is implemented under OS Kernel level. The Linux kernel contains an MD driver that allows the RAID solution to be completely hardware independent.
The performance of a software-based array depends on the server CPU performance and load.
8.What is the difference between cron and anacron
Ans Cron :
1) Minimum granularity is minute (i.e Jobs can be scheduled to be executed
every minute)
2) Cron job can be scheduled by any normal user ( if not restricted by super
user )
3) Cron expects system to be running 24 x 7. If a job is scheduled, and
system is down during that time, job is not executed
4) Ideal for servers
5) Use cron when a job has to be executed at a particular hour and minute
Anacron :
1) Minimum granularity is only in days
2) Anacron can be used only by super user ( but there are workarounds to
make it usable by normal user )
3) Anacron doesn’t expect system to be running 24 x 7. If a job is scheduled,
and system is down during that time, it start the jobs when the system
comes back up.
4) Ideal for desktops and laptops
5) Use anacron when a job has to be executed irrespective of hour and
minute
9.What is CUPS?
CUPS stands for "Common UNIX Printing System". CUPS is a open source printing system developed by Apple Inc. CUPS uses the Internet Printing Protocol (IPP) to allow local printing and print sharing.
The log files for the CUPS printing system are located in the /var/log/cups/ directory.
10.How Many Run Levels present in Linux?
There are 7 run levels, with each having its own properties.
- 0: Halt the system
- 1: Single-user mode
- 2: Not used
- 3: Multi-user mode with text login
- 4: Not used
- 5: Multi-user mode with graphical login
- 6: Reboot
-----------------------------------------------------------------------------------------------------------------------------
Directories and Files :
## Directories
/etc/lvm - default lvm directory location
/etc/lvm/backup - where the automatic backups go
/etc/lvm/cache - persistent filter cache
/etc/lvm/archive - where automatic archives go after a volume group change
/var/lock/lvm - lock files to prevent metadata corruption
# Files
/etc/lvm/lvm.conf - main lvm configuration file
$HOME/.lvm - lvm history
Diagnostics :
#lvmdump
#lvmdump -d
# dmsetup [info|ls|status]
// Note: by default the lvmdump command creates a tar ball
Display :
# pvdisplay -v
# pvs -v
# pvs -a
Scanning :
#pvscan -v
Note: scans for disks for non-LVM and LVM disks
Add / Remove / Check PV:
# pvcreate /dev/sdb1
# pvremove /dev/sdb1
#pvck -v /dev/sdb1
Change physical attributes:
## do not allow allocation of extents on this drive
#pvchange -x n /dev/sdb1
- Common Attributes that you may want to use:
--addtag add a tag
-x allowed to allocate extents
-u change the uuid
Move PV :
# pvmove -v /dev/sdb2 /dev/sdb3
Note: moves any used extents from this volume to another volume, in readiness to remove that volume. However you cannot use this on mirrored volumes, you must convert back to non-mirror using "lvconvert -m 0"
This post will help you to keep remember Volume Group - VG related commands in Linux at the time of interview Preparation.
Display Volume Group
vgdisplay -v
vgs -v
vgs -a -o +devices
vgs flags:
#PV - number of physical devices
#LV - number of configured volumes
vgs attributes are:
1. permissions (r)|(w)
2. resi(z)eable
3. e(x)ported
4. (p)artial
5. allocation policy - (c)ontiguous, c(l)ing, (n)ormal, (a)nywhere, (i)nherited
6. (c)luster
Create VG :
vgcreate VolData00 /dev/sdb1 /dev/sdb2 /dev/sdb3
vgcreate VolData00 /dev/sdb[123]
## Use 32MB extent size
# vgcreate VGName -s 32 /dev/sdb1
Common Attributes that you may want to use:
-l maximum logical volumes
-p maximum physical volumes
-s physical extent size (default is 4MB)
-A autobackup
Extend / Reduce / Remove Volume Group :
vgextend VGName /dev/sdb3
vgreduce VGName /dev/sdb3
vgreduce --removemissing --force VolData00
vgremove VGName
Change in VG :
vgchange -a n VolData00
Common Attributes that you may want to use:
-a control availability of volumes within the group
-l maximum logical volumes
-p maximum physical volumes
-s physical extent size (default is 4MB)
-x resizable yes or no (see VG status in vxdisplay)
Check and rename Volume Group :
#vgrename VGName VGName_New //no LV should be activate at the time of rename
#vgck VolData00 //checking consistency of Meta data
Convert / Merge / Split Volume Group:
#vgconvert -M2 VGName //convert one type to anothe type (lvm1 to lvm2)
#vgmerge New_Vol_Group Old_Vol_Group /old vg will be merged to new VG
#vgsplit Old_Vol_Group New_Vol_Group [physical volumes] [-n logical volume name]
Import / Export Volume Group
#vgimport VGName
#vgexport VGName
Backup and Restore:
# vgcfgbackup VGname
# vgcfgrestore -f /var/backup/VGname_bkup VGName
Display:
#lvdisplay -v lvname
#lvs
To view mirror volumes
#lvs -a -o +devices
#lvs -a -o +seg_pe_ranges --segments
lvs attributes are:
1. volume type: (m)irrored, (M)irrored without initail sync, (o)rigin, (p)vmove, (s)napshot, invalid (S)napshot, (v)irtual, mirror (i)mage
mirror (I)mage out-of-sync, under (c)onversion
2. permissions: (w)rite, (r)ead-only
3. allocation policy - (c)ontiguous, c(l)ing, (n)ormal, (a)nywhere, (i)nherited
4. fixed (m)inor
5. state: (a)ctive, (s)uspended, (I)nvalid snapshot, invalid (S)uspended snapshot, mapped (d)evice present with-out tables,
mapped device present with (i)nactive table
6. device (o)pen (mounted in other words)
Scan:
#lvscan -v
#lvmdiskscan
Create / Extend / Reduce / Remove:
Create a Lvol
#lvcreate -L 10M -n lvol1 VGNAME // To create plain lvol
#lvcreate -i 3 -I 32 -L 24M -n lvol1 vg01 //To create striped lvol
#lvcreate -L 10M -m1 -n lvol1 vg01 // To Create mirror lvol
Extend a Lvol
#lvextend -L 20M /dev/VolData00/lvol01
#fsadm resize /dev/VolData01/data01
#resize2fs -p /dev/mapper/VolData01-data01 [size]
Reduce Lvol
#lvreduce -L 5M /dev/VolData00/lvol01 (or)
#lvresize -L 5M /dev/VolData00/lvol01
#fsadm resize /dev/VolData01/data01 [size]
#resize2fs -p /dev/mapper/VolData01-data01 [size]
Rename / Snapshot / change attribute
# lvrename /dev/VolData00/vol_old /dev/VolData00/vol_new //Rename
# lvcreate --size 100M --snapshot -name snap /dev/vg01/data01 //Snapshot
#lvchange -a n /dev/VolData00/vol01 //Changing attribute
Regular tasks
Questions: PART 2
1.What are LVM1 and LVM2?
2.What is the maximum size of a single LV?
3.List of important LVM related files and Directories?
4.What is the steps to create LVM in Linux?
5.How to extend a File system in Linux?
6.How to reduce the File system size in Linux?
7.How to add new LUN from storage to Linux server?
8.How to resize root file system on RHEL 6?
9.How to find server is configured with LVM RAID ?
10.How to check Linux server is configured with power path disks?
11.How to check server is configured with Multipath disks??
Answers:
1.What are LVM1 and LVM2?
LVM1 and LVM2 are the versions of LVM.
LVM2 uses device mapper driver contained in 2.6 kernel version.
LVM 1 was included in the 2.4 series kernels.
2.What is the maximum size of a single LV?
For 2.4 based kernels, the maximum LV size is 2TB.
For 32-bit CPUs on 2.6 kernels, the maximum LV size is 16TB.
For 64-bit CPUs on 2.6 kernels, the maximum LV size is 8EB.
3.List of important LVM related files and Directories?
## Directories
/etc/lvm - default lvm directory location
/etc/lvm/backup - where the automatic backups go
/etc/lvm/cache - persistent filter cache
/etc/lvm/archive - where automatic archives go after a volume group change
/var/lock/lvm - lock files to prevent metadata corruption
# Files
/etc/lvm/lvm.conf - main lvm configuration file
$HOME/.lvm - lvm history
4.What is the steps to create LVM in Linux?
Create a physical volume by using pvcreate command
consider the disk is local.
#fdisk -l
#fdisk /dev/sda
Press "n" to create new partition. And mention the size / allocate whole disk to single partition. and assign the partition number also.
#press "t" to change the partition as LVM partition.
#enter "8e" ( 8e - is Hex decimal code for LVM )
#Enter "w" to write tghe information on Disk.
#fdisk -l ( Now you will get newly created disk numbers)
#pvcreate /dev/sda2
Add physical volume to volume group by “vgcreate” command
#vgcreate VLG0 /dev/sda2
Create logical volume from volume group by “lvcreate” command.
#lvcreate -L 1G -n LVM1 VG0
Now create file system on /dev/sda2 partition by “mke2fs” or "mkfs.ext3" command.
#mke2fs -j /dev/VG0/LVM1
or
#mkfs.ext3 /dev/vg0/LVM1
How to mount this as file system
#mkdir /test
#mount /dev/VG0/LVM1 /test
5.How to extend a File system in Linux?
Check the free space on vg
#vgdisplay -v VG1
Now extend the FS
# lvextend -L+1G /dev/VG1/lvol1
# resize2fs /dev/VG1/lvol1
6.How to reduce the File system size in Linux?
1.First we need to reduce the file system size using "resize2fs"
2.Then reduce the lvol size using "lvreduce"
#resize2fs -f /dev/VolGroup00/LogVol00 3G
#lvreduce -L 5G /dev/VG1/Lvol1
7.How to add new LUN from storage to Linux server?
Step 1: Get the list of HBA and exisiting disk details.
#ls /sys/class/fc_host
#fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l
Step 2: Scan the HBA ports (Need to scan all HBA port)
#echo "1" > /sys/class/fc_host/host??/issue_lip
# echo "- - -" > /sys/class/scsi_host/host??/scan
Do this above steps for all HBA cards
Step3 : Check the newly added Lun
# cat /proc/scsi/scsi | egrep -i 'Host:' | wc -l
# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l
Once found the disk then do below steps to add to VolumeGroup
#pvcreate /dev/diskpath
#vgextend /dev/vg1 /dev/diskpath
#vgs or #vgdisplay /dev/vg1
8.How to resize root file system on RHEL 6?
Here is the list of steps to reduce the root file system (lv_root) on a RHEL 6 Linux server:
Boot the system into rescue mode. Do not mount the file systems (select the option to 'Skip' in the rescue mode and start a shell)
Bring the Volume Group online
#lvm vgchange -a -y
Run fsck on the FS
#e2fsck -f /dev/vg_myhost/lv_root
Resize the file system with new size
#resize2fs -f /dev/vg00/lv_root 20G
Reduce the Logical Volume of the FS with the new size
#lvreduce -L20G /dev/vg00/lv_root
Run fsck to make sure the FS is still ok
#e2fsck -f /dev/vg00/lv_root
Optionally mount the file system in the rescue mode
#mkdir -p /mnt/sysimage/root
#mount -t ext4 /dev/mapper/vg00-lv_root /mnt/sysimage/root
#cd /mnt/sysimage/root
Unmount the FS
#cd
#umount /mnt/sysimage/root
Exit rescue mode and boot the system from the hard disk
#exit
Select the reboot option from the recue mode
9.How to find server is configured with LVM RAID ?
1.How to check linux LVM RAID ?
check the RAID status in /proc/mdstat
#cat /proc/mdstat
or
# mdadm --detail /dev/mdx
or
# lsraid -a /dev/mdx
2.Check the Volume group disks
#vgdisplay -v vg01
In disk we will get the device names like /dev/md1 , /dev/md2 . It means LVM RAID disks are configured and its added to Volume Group.
10.How to check Linux server is configured with power path disks?
1.Check power path is installed on server?
#rpm -qa |grep -i emc
2.Check the power path status on server?
#/etc/init.d/PowerPath status
#chkconfig --list PowerPath
# lsmod |grep -i emc
3.Check the Volume group disks
#vgdisplay -v vg01
In disk we will get the device names like /dev/emcpowera , /dev/emcpowerb . It means powerpath disks are configured and its added to Volume Group.
4.Check the power path disk status using below command
#powermt display dev=all
11.How to check server is configured with Multipath disks??
# ls -lrt /dev/mapper //To View the Mapper disk paths and Lvols
#dmsetup table
#dmsetup ls
#dmsetup status
2.Using Multipathd Command ( Daemon )
#echo 'show paths' |multipathd -k
#echo 'show maps' |multipathd -k
3.Check multipath Daemon is running or not
#ps -eaf |grep -i multipathd
4.check the VG disk paths
#vgs or vgdisplay -v vg01
If multipath disks are added and configured with VG then we will get disk paths like /dev/mpath0 , /dev/mpath1.
5.If you want to check the disk path status u can use below command also
#multipathd -k
#multipathd> show multipaths status
#multipathd> show topology
#multipathd> show paths
--------------------------------------------------------------------------------------------------------------------------------------------------------
PV commands in Linux - LVM interview Questions
PV related commands in Linux LVM :
Directories and Files :
## Directories
/etc/lvm - default lvm directory location
/etc/lvm/backup - where the automatic backups go
/etc/lvm/cache - persistent filter cache
/etc/lvm/archive - where automatic archives go after a volume group change
/var/lock/lvm - lock files to prevent metadata corruption
# Files
/etc/lvm/lvm.conf - main lvm configuration file
$HOME/.lvm - lvm history
Diagnostics :
#lvmdump
#lvmdump -d
# dmsetup [info|ls|status]
// Note: by default the lvmdump command creates a tar ball
PHYSICAL VOLUME
Display :
# pvdisplay -v
# pvs -v
# pvs -a
Scanning :
#pvscan -v
Note: scans for disks for non-LVM and LVM disks
Add / Remove / Check PV:
# pvcreate /dev/sdb1
# pvremove /dev/sdb1
#pvck -v /dev/sdb1
Change physical attributes:
## do not allow allocation of extents on this drive
#pvchange -x n /dev/sdb1
- Common Attributes that you may want to use:
--addtag add a tag
-x allowed to allocate extents
-u change the uuid
Move PV :
# pvmove -v /dev/sdb2 /dev/sdb3
Note: moves any used extents from this volume to another volume, in readiness to remove that volume. However you cannot use this on mirrored volumes, you must convert back to non-mirror using "lvconvert -m 0"
VG Related command tips in Linux:
This post will help you to keep remember Volume Group - VG related commands in Linux at the time of interview Preparation.
Display Volume Group
vgdisplay -v
vgs -v
vgs -a -o +devices
vgs flags:
#PV - number of physical devices
#LV - number of configured volumes
vgs attributes are:
1. permissions (r)|(w)
2. resi(z)eable
3. e(x)ported
4. (p)artial
5. allocation policy - (c)ontiguous, c(l)ing, (n)ormal, (a)nywhere, (i)nherited
6. (c)luster
Create VG :
vgcreate VolData00 /dev/sdb1 /dev/sdb2 /dev/sdb3
vgcreate VolData00 /dev/sdb[123]
## Use 32MB extent size
# vgcreate VGName -s 32 /dev/sdb1
Common Attributes that you may want to use:
-l maximum logical volumes
-p maximum physical volumes
-s physical extent size (default is 4MB)
-A autobackup
Extend / Reduce / Remove Volume Group :
vgextend VGName /dev/sdb3
vgreduce VGName /dev/sdb3
vgreduce --removemissing --force VolData00
vgremove VGName
Change in VG :
vgchange -a n VolData00
Common Attributes that you may want to use:
-a control availability of volumes within the group
-l maximum logical volumes
-p maximum physical volumes
-s physical extent size (default is 4MB)
-x resizable yes or no (see VG status in vxdisplay)
Check and rename Volume Group :
#vgrename VGName VGName_New //no LV should be activate at the time of rename
#vgck VolData00 //checking consistency of Meta data
Convert / Merge / Split Volume Group:
#vgconvert -M2 VGName //convert one type to anothe type (lvm1 to lvm2)
#vgmerge New_Vol_Group Old_Vol_Group /old vg will be merged to new VG
#vgsplit Old_Vol_Group New_Vol_Group [physical volumes] [-n logical volume name]
Import / Export Volume Group
#vgimport VGName
#vgexport VGName
Backup and Restore:
# vgcfgbackup VGname
# vgcfgrestore -f /var/backup/VGname_bkup VGName
Logical Volume in LVM: Interview Questions
Display:
#lvdisplay -v lvname
#lvs
To view mirror volumes
#lvs -a -o +devices
#lvs -a -o +seg_pe_ranges --segments
lvs attributes are:
1. volume type: (m)irrored, (M)irrored without initail sync, (o)rigin, (p)vmove, (s)napshot, invalid (S)napshot, (v)irtual, mirror (i)mage
mirror (I)mage out-of-sync, under (c)onversion
2. permissions: (w)rite, (r)ead-only
3. allocation policy - (c)ontiguous, c(l)ing, (n)ormal, (a)nywhere, (i)nherited
4. fixed (m)inor
5. state: (a)ctive, (s)uspended, (I)nvalid snapshot, invalid (S)uspended snapshot, mapped (d)evice present with-out tables,
mapped device present with (i)nactive table
6. device (o)pen (mounted in other words)
Scan:
#lvscan -v
#lvmdiskscan
Create / Extend / Reduce / Remove:
Create a Lvol
#lvcreate -L 10M -n lvol1 VGNAME // To create plain lvol
#lvcreate -i 3 -I 32 -L 24M -n lvol1 vg01 //To create striped lvol
#lvcreate -L 10M -m1 -n lvol1 vg01 // To Create mirror lvol
Extend a Lvol
#lvextend -L 20M /dev/VolData00/lvol01
#fsadm resize /dev/VolData01/data01
#resize2fs -p /dev/mapper/VolData01-data01 [size]
Reduce Lvol
#lvreduce -L 5M /dev/VolData00/lvol01 (or)
#lvresize -L 5M /dev/VolData00/lvol01
#fsadm resize /dev/VolData01/data01 [size]
#resize2fs -p /dev/mapper/VolData01-data01 [size]
Rename / Snapshot / change attribute
# lvrename /dev/VolData00/vol_old /dev/VolData00/vol_new //Rename
# lvcreate --size 100M --snapshot -name snap /dev/vg01/data01 //Snapshot
#lvchange -a n /dev/VolData00/vol01 //Changing attribute
Unix- LVM commonly asked Interview questions..
Regular tasks
I) How to create a Volume Group (VG).
II) How to create a Logical Volume (LV) and mount the file system.
III) How to add a disk to a Volume Group
IV) How to increase the size of a logical volume without OnlineJFS
V) How to remove a Logical Volume
VI) How to reduce the size of a logical volume without OnlineJFS (advanced JFS)
VII) How to remove a disk from a volume group
VIII) How to remove a volume group
IX) How to increase the primary swap
X) How to create a secondary boot disk LVM Mirroring
XI) How to mirror a logical volume
1.What are LVM1 and LVM2?
2.What is the maximum size of a single LV?
3.List of important LVM related files and Directories?
4.What is the steps to create LVM in Linux?
5.How to extend a File system in Linux?
6.How to reduce the File system size in Linux?
7.How to add new LUN from storage to Linux server?
8.How to resize root file system on RHEL 6?
9.How to find server is configured with LVM RAID ?
10.How to check Linux server is configured with power path disks?
11.How to check server is configured with Multipath disks??
Answers:
1.What are LVM1 and LVM2?
LVM1 and LVM2 are the versions of LVM.
LVM2 uses device mapper driver contained in 2.6 kernel version.
LVM 1 was included in the 2.4 series kernels.
2.What is the maximum size of a single LV?
For 2.4 based kernels, the maximum LV size is 2TB.
For 32-bit CPUs on 2.6 kernels, the maximum LV size is 16TB.
For 64-bit CPUs on 2.6 kernels, the maximum LV size is 8EB.
3.List of important LVM related files and Directories?
## Directories
/etc/lvm - default lvm directory location
/etc/lvm/backup - where the automatic backups go
/etc/lvm/cache - persistent filter cache
/etc/lvm/archive - where automatic archives go after a volume group change
/var/lock/lvm - lock files to prevent metadata corruption
# Files
/etc/lvm/lvm.conf - main lvm configuration file
$HOME/.lvm - lvm history
4.What is the steps to create LVM in Linux?
Create a physical volume by using pvcreate command
consider the disk is local.
#fdisk -l
#fdisk /dev/sda
Press "n" to create new partition. And mention the size / allocate whole disk to single partition. and assign the partition number also.
#press "t" to change the partition as LVM partition.
#enter "8e" ( 8e - is Hex decimal code for LVM )
#Enter "w" to write tghe information on Disk.
#fdisk -l ( Now you will get newly created disk numbers)
#pvcreate /dev/sda2
Add physical volume to volume group by “vgcreate” command
#vgcreate VLG0 /dev/sda2
Create logical volume from volume group by “lvcreate” command.
#lvcreate -L 1G -n LVM1 VG0
Now create file system on /dev/sda2 partition by “mke2fs” or "mkfs.ext3" command.
#mke2fs -j /dev/VG0/LVM1
or
#mkfs.ext3 /dev/vg0/LVM1
How to mount this as file system
#mkdir /test
#mount /dev/VG0/LVM1 /test
5.How to extend a File system in Linux?
Check the free space on vg
#vgdisplay -v VG1
Now extend the FS
# lvextend -L+1G /dev/VG1/lvol1
# resize2fs /dev/VG1/lvol1
6.How to reduce the File system size in Linux?
1.First we need to reduce the file system size using "resize2fs"
2.Then reduce the lvol size using "lvreduce"
#resize2fs -f /dev/VolGroup00/LogVol00 3G
#lvreduce -L 5G /dev/VG1/Lvol1
7.How to add new LUN from storage to Linux server?
Step 1: Get the list of HBA and exisiting disk details.
#ls /sys/class/fc_host
#fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l
Step 2: Scan the HBA ports (Need to scan all HBA port)
#echo "1" > /sys/class/fc_host/host??/issue_lip
# echo "- - -" > /sys/class/scsi_host/host??/scan
Do this above steps for all HBA cards
Step3 : Check the newly added Lun
# cat /proc/scsi/scsi | egrep -i 'Host:' | wc -l
# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l
Once found the disk then do below steps to add to VolumeGroup
#pvcreate /dev/diskpath
#vgextend /dev/vg1 /dev/diskpath
#vgs or #vgdisplay /dev/vg1
8.How to resize root file system on RHEL 6?
Here is the list of steps to reduce the root file system (lv_root) on a RHEL 6 Linux server:
Boot the system into rescue mode. Do not mount the file systems (select the option to 'Skip' in the rescue mode and start a shell)
Bring the Volume Group online
#lvm vgchange -a -y
Run fsck on the FS
#e2fsck -f /dev/vg_myhost/lv_root
Resize the file system with new size
#resize2fs -f /dev/vg00/lv_root 20G
Reduce the Logical Volume of the FS with the new size
#lvreduce -L20G /dev/vg00/lv_root
Run fsck to make sure the FS is still ok
#e2fsck -f /dev/vg00/lv_root
Optionally mount the file system in the rescue mode
#mkdir -p /mnt/sysimage/root
#mount -t ext4 /dev/mapper/vg00-lv_root /mnt/sysimage/root
#cd /mnt/sysimage/root
Unmount the FS
#cd
#umount /mnt/sysimage/root
Exit rescue mode and boot the system from the hard disk
#exit
Select the reboot option from the recue mode
9.How to find server is configured with LVM RAID ?
1.How to check linux LVM RAID ?
check the RAID status in /proc/mdstat
#cat /proc/mdstat
or
# mdadm --detail /dev/mdx
or
# lsraid -a /dev/mdx
2.Check the Volume group disks
#vgdisplay -v vg01
In disk we will get the device names like /dev/md1 , /dev/md2 . It means LVM RAID disks are configured and its added to Volume Group.
10.How to check Linux server is configured with power path disks?
1.Check power path is installed on server?
#rpm -qa |grep -i emc
2.Check the power path status on server?
#/etc/init.d/PowerPath status
#chkconfig --list PowerPath
# lsmod |grep -i emc
3.Check the Volume group disks
#vgdisplay -v vg01
In disk we will get the device names like /dev/emcpowera , /dev/emcpowerb . It means powerpath disks are configured and its added to Volume Group.
4.Check the power path disk status using below command
#powermt display dev=all
11.How to check server is configured with Multipath disks??
# ls -lrt /dev/mapper //To View the Mapper disk paths and Lvols
#dmsetup table
#dmsetup ls
#dmsetup status
2.Using Multipathd Command ( Daemon )
#echo 'show paths' |multipathd -k
#echo 'show maps' |multipathd -k
3.Check multipath Daemon is running or not
#ps -eaf |grep -i multipathd
4.check the VG disk paths
#vgs or vgdisplay -v vg01
If multipath disks are added and configured with VG then we will get disk paths like /dev/mpath0 , /dev/mpath1.
5.If you want to check the disk path status u can use below command also
#multipathd -k
#multipathd> show multipaths status
#multipathd> show topology
#multipathd> show paths
--------------------------------------------------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment