Tips and Tricks


  • Screen I am not the first one to mention that. I just didn’t use it for such a long time even after knowing it. It a great tool and must for all the  SysAdmins and Developers.


  • Resetting the master on github

Reset your local master to the point you want, then `git push –force origin’

Some powerful commands on Linux

Adding ISO as repository on Fedora/RHEL/CentOS

Do a loop-back mount of the ISO and then add following in the yum.conf file.


Debian Package

Any file in /etc directory is treated as configuration files.They are not removed after un-installing the package. To remove those
files run:

$dpkg –purge <package name>
Make sure you don’t remove them manually. If you did then run:
$ dpkg  –force-confnew <package>.deb
This will re-install the configuration files.

In my case, in the post section I was  removing them manually, which was causing the problem next time while installing package.

I had to install a init script and dpkg was giving following error:-

update-rc.d: /etc/init.d/blah: file does not exist

dpkg was assuming that the file “/etc/init.d” is already and the not copying it again.

dd command status

?dd command doesn’t give us the status, So if you put very large copy using then you just have to wait till it finishes.

Run following command

kill -USR1 <pid of dd process>

and you get some status on the terminal you were running the command. You can run  above command as many times you want to get the status.

Finding the SCSI id for a disk and its controller

If we look at “/proc/scsi/scsi” file then we see something like following:-

Host: scsi1 Channel: 00 Id: 00 Lun: 22

Vendor: HP Model: P2000 G3 FC Rev: T201

Type: Direct-Access ANSI SCSI revision

And we look at dmesg output then we see :-

sd 1:0:0:22: [sde] 683593728 512-byte logical blocks: (349 GB/325 GiB)

sd 1:0:0:22: [sde] Write Protect is off

sd 1:0:0:22: [sde] Mode Sense: 93 00 00 08

sd 1:0:0:22: [sde] Attached SCSI disk

From above we can conclude that “sde” is the disk which is attached on host 1 and have Lun Id as 22. We can also see that the disk is coming from HP P2000 G3 FC storage. 

A typical SCSI nameing convention is

<host> <channel> <target> <lun>

Scanning for newly attached disk on the FC HBA

To scan the given “host (h)” , “channel(c)””, “target(t)” and “lun(l)” , run following command :-

$echo “<c> <t> <l>” > /sys/class/scsi_host/host<h>/scan

And to scan all channels, target and luns for a give host run following:-

$ echo “- – -” > /sys/class/scsi_host/host<h>/scan

Using SAR (system activity report)

It is used to collect, report, or save system activity information. It can report CPU, Disk, Memory, Network, paging and other information. If configured with cron then it collects information everyday and store the statistics in “/var/log/sa” folder. The “saX” files are binary files and “sarX” file are human readable data, where is day of the month. We can collect all those stats manually as well.

Following command will collect Disk, CPU, Memory, paging, load average stats in every 5 mins and save it in “logfile” file in binary format:-

$ sar -dp -u -r -B -q 5 -o <logfile>

And with following the binary file can be coverted into CSV file:-

$ sadf -d — -dp -u -r -B -q 5 <logfile> > <csvfile>

Make sure “sar” and “sadf” is run on the same system, else the name of the disks in CSV file would change.


Comments (5)

Leave a Reply