Labels

hpunix (63) marathi kavita (52) linux (21) solaris11 (11) AWS (5) numerology (5)

Friday, March 10, 2017

Linux Query or Interview question - 7

Query 1. Which output to take from server if doing any activity like patching, reboot, kernel upgrade?

Ans: If you are doing any activity on server, it is always better to have backup of important files, in IT term we call it as “pre activity output”. So in case of any issue happened on server then we will be able to resolve it by comparing the pre and post activity output.

You should take below output as pre-activity output, as there are chances that below files/parameters may get change after reboot.

a. #df –h = to see mounted FS details including NFS
b. #cat /etc/fstab = to see all FS details
c.  #cat /etc/hosts = all hosts entries added on server
d. #cat /etc/resolv.conf = to get nameserver details, FQDN etc..
e. #ifconfig –a = to get all IP information including binding IP, virtual IP etc.., MAC ID
f. #netstat –rn = to get routing information
g. #ntpq –p = ntp server information

[root@testmachine kijadhav]# df -h > pre_activity_op.`date +"%d%m%y"`
[root@testmachine kijadhav]# ls -lrt pre*
-rw-r--r-- 1 root root 845 Mar 10 09:15 pre_activity_op.100317
[root@testmachine kijadhav]# cat /etc/fstab >> pre_activity_op.100317
[root@testmachine kijadhav]# cat /etc/hosts >> pre_activity_op.100317
[root@testmachine kijadhav]# cat /etc/resolv.conf >> pre_activity_op.100317
[root@testmachine kijadhav]# ifconfig -a >> pre_activity_op.100317
[root@testmachine kijadhav]# netstat -rn >> pre_activity_op.100317
[root@testmachine kijadhav]# ntpq -p >> pre_activity_op.100317

Don’t save this output on server itself, incase server is not up then what will you see J So better mail this output to your outlook to keep it handy.

[root@ testmachine ~]# mail –a pre_activity_op.100317 –s “pre activity out_testmachine” kiran.jadhav@abc.com

Query 2: How to scan new Luns/disks by using for loop.

Ans: If we are having multiple hosts under /sys/class/scsi_host then we will run echo command for discovering luns/disks for multiple times. To avoid this just use for loop and by running one command you can scan all luns which are coming from different different hosts (host0, host1…..)

[root@ testmachine boot]# for i in `ls /sys/class/scsi_host`;do echo "- - -" > "/sys/class/scsi_host/$i/scan";done

Thanks & Regards,
Kiran Jadhav




No comments:

Post a Comment