Monday, September 29, 2008

Useful commands

If you want to get some information about your laptop:

root@arrow:~# dmidecode -s system-manufacturer
LENOVO
root@arrow:~# dmidecode -s system-product-name
6371EXU
root@arrow:~# dmidecode -s system-version
ThinkPad T60

1 comment:

Magda said...

List open files:

From:

http://www.linuxjournal.com/content/list-open-files

If you try to unmount a partition and get a message like this:

# umount /media/usbdisk/
umount: /media/usbdisk: device is busy

use the lsof command to find out what programs are using what files:

# lsof /media/usbdisk/
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
bash 6925 root cwd DIR 8,17 4096 1 /media/usbdisk/
xmms 6979 root cwd DIR 8,17 4096 1 /media/usbdisk/

This shows that the programs bash and xmms are using the device. For an even clearer picture, use the device name rather than the mountpoint:

# lsof /dev/sdb1
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
bash 6925 root cwd DIR 8,17 4096 1 /media/usbdisk
xmms 6979 root cwd DIR 8,17 4096 1 /media/usbdisk
xmms 6979 root 8r REG 8,17 2713101 377 /media/usbdisk/a.mp3

You either can wait until those processes exit or terminate them manually.