Table of Contents
Abstract
A number of programs and mechanisms, some of which are presented here, can be used to examine the status of your system. Also described are some utilities that are useful for routine work, along with their most important parameters.
For each of the commands introduced, examples of the relevant outputs are presented. In these examples, the first line is the command itself (after the dollar sign prompt). Comments are indicated by the use of square brackets [...] and long lines are wrapped where necessary. Line breaks for long lines are indicated by a backslash (\).
$ command -x -y output line 1 output line 2 output line 3 is annoyingly long, so long that \ we have to break it output line 3 [...] output line 98 output line 99
The descriptions have been kept short to allow as many utilities as possible to be mentioned. Further information for all the commands can be found in the man pages. Most of the commands also understand the parameter --help, which produces a brief list of the possible parameters.
To view a list of all the files open for the process with process ID PID, use -p. For example, to view all the files used by the current shell, enter:
$ lsof -p $$ COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME zsh 4694 jj cwd DIR 0,18 144 25487368 /suse/jj/t (totan:/real-home/jj) zsh 4694 jj rtd DIR 3,2 608 2 / zsh 4694 jj txt REG 3,2 441296 20414 /bin/zsh zsh 4694 jj mem REG 3,2 104484 10882 /lib/ld-2.3.3.so zsh 4694 jj mem REG 3,2 11648 20610 /usr/lib/zsh/4.2.0/zsh/rlimits.so [...] zsh 4694 jj mem REG 3,2 13647 10891 /lib/libdl.so.2 zsh 4694 jj mem REG 3,2 88036 10894 /lib/libnsl.so.1 zsh 4694 jj mem REG 3,2 316410 147725 /lib/libncurses.so.5.4 zsh 4694 jj mem REG 3,2 170563 10909 /lib/tls/libm.so.6 zsh 4694 jj mem REG 3,2 1349081 10908 /lib/tls/libc.so.6 zsh 4694 jj mem REG 3,2 56 12410 /usr/lib/locale/de_DE.utf8/LC_TELEPHONE [...] zsh 4694 jj mem REG 3,2 59 14393 /usr/lib/locale/en_US/LC_NUMERIC zsh 4694 jj mem REG 3,2 178476 14565 /usr/lib/locale/en_US/LC_CTYPE zsh 4694 jj mem REG 3,2 56444 20598 /usr/lib/zsh/4.2.0/zsh/computil.so 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
The special shell variable $$, whose value is the process ID of the shell, has been used.
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