Home Linux Community Forums Software Command Line Share your best command line scripts

Share your best command line scripts

Link to this post 06 Feb 10

Here are a couple I use at work a lot.

This one will identify the manufacturer of a NIC card based on the most current published list of OUIs. It takes the MAC address as the argument and is forgiving of the format (e.g. ifconfig, windows ipconfig, or cisco style)


OUI=$(echo ${1//[:.-]/} | tr "[a-f]" "[A-F]" | egrep -o "^[0-9A-F]{6}")
lynx -dump | grep $OUI

Here's one I use to mount the file system inside my Virtual Box .vdi disk image when I need to grab a file, but do not need to otherwise fireup the virtual machine:


if [ -f ~/.VirtualBox/VDI/$1 ]
MOUNT=`sudo mount -o loop,umask=0000,offset=0x$(hd -n 1000000 ~/.VirtualBox/VDI/$1 | grep "eb 52 90 4e 54 46 53" | cut -c 1-8) ~/.VirtualBox/VDI/$1 /mnt 2>&1`
if [ "$?" -ne "0" ]
echo -e "Mount Failed!!!!\n"
OUT=`echo $MOUNT | grep "indicates unclean shutdown" 2>&1`
if [ "$?" -eq "0" ]
echo "NTFS was not cleanly unmounted"
sudo losetup -d /dev/loop0
exit 0
echo "$1 - files not found"

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Linux Training / Board