Datasheet

“main” (Installation and Administration) 2004/6/25 13:29 page 709 #735
i
i
i
i
i
i
i
i
28
System Monitoring Utilities
The command lsof lists all the files currently open when used without
any parameters. Usually a huge number of files will be open. To find out
how many files are open, enter the following:
$ lsof | wc -l
3749
List all the character devices used with:
$ lsof | grep CHR
sshd 4685 root mem CHR 1,5 45833 /dev/zero
sshd 4685 root mem CHR 1,5 45833 /dev/zero
sshd 4693 jj mem CHR 1,5 45833 /dev/zero
sshd 4693 jj mem CHR 1,5 45833 /dev/zero
zsh 4694 jj 0u CHR 136,48 50 /dev/pts/48
zsh 4694 jj 1u CHR 136,48 50 /dev/pts/48
zsh 4694 jj 2u CHR 136,48 50 /dev/pts/48
zsh 4694 jj 10u CHR 136,48 50 /dev/pts/48
X 6476 root mem CHR 1,1 38042 /dev/mem
lsof 13478 jj 0u CHR 136,48 50 /dev/pts/48
lsof 13478 jj 2u CHR 136,48 50 /dev/pts/48
grep 13480 jj 1u CHR 136,48 50 /dev/pts/48
grep 13480 jj 2u CHR 136,48 50 /dev/pts/48
28.2 User Accessing Files: fuser
Suppose that we want to unmount a file system under /mnt:
$ mount -l | grep /mnt
/dev/sda on /mnt type ext2 (rw,noexec,nosuid,nodev,noatime,user=jj)
The attempt to unmount it fails:
$ umount /mnt
umount: /mnt: device is busy
To find out which processes are accessing the files in the /mnt directory,
enter:
$ fuser -v /mnt/*
USER PID ACCESS COMMAND
/mnt/notes.txt
jj 26597 f.... less
Following termination of the less process, which was running on another
terminal, the file system can successfully be unmounted.
709
SUSE LINUX Enterprise Server