One-Liners

Ever come across a useful command and think to yourself, “I should keep this somewhere so I can remember it!”?  Well, that is exactly what this page is for!  Here you will find various commands or short scripts that I have found useful over the years.  As I come across more of these I will continuously update this page.  Please note:  I cannot take credit for a lot of these commands / tips.  I will attempt to credit the appropriate authors where possible.

Bash / Linux

Install VMware tools inside of Linux VM:

Credit:  F. Grau
Description:  Installs VMware tools inside Linux guest VM (assuming tools ISO is presented to guest)

mount /dev/cdrom /media; rm -fr /tmp/x1; mkdir /tmp/x1; cd /tmp/x1; tar -zxf /media/V*tar*; cd vm*; ./vm*pl -d; cd; rm -fr /tmp/x1

Transfer files from one server to another with ssh & tar:

Credit:  F. Grau
Description:  Puts files in current directory
ssh root@fooserver "cd /data && tar -cf - * " | tar -xf -

Sort and rank of who is using sudo:

egrep -o “sudo:\s+\S+\s+:” /var/log/secure | sort | uniq -c | sort -g

Re-scanning the SCSI bus on a Linux host (useful when hot adding virtual disks):

echo “- – -” > /sys/class/scsi_host/host0/scan

 

Windows

PuTTY — Exit a ‘stuck’ SSH session:

Description:  If you have an SSH shell that gets ‘stuck’ for whatever reason (disconnect, reboot, hung, etc.), simply press ~. (tilde, dot).  That should drop you back to the originating shell / SSH client program.

Miscellaneous

How to reset a HP iLO device:

Description:  While working with a HP iLO device, occasionally the iLO will completely freeze and need to be reset.  If you can get to it via SSH, you can run these commands to reboot the iLO device itself (does not reboot server):

</>hpiLO-> cd /MAP1

status=0
status_tag=COMMAND COMPLETED
Mon May 6 12:55:34 2013

</MAP1>hpiLO-> RESET

status=0
status_tag=COMMAND COMPLETED
Mon May 6 12:55:39 2013

Resetting iLO.