Using System Information Tools

Sometimes you need to know things about your computer—where partitions are mounted, how much memory is in use, and so on. Linux provides a number of commands that provide this information. Examples include:

df This command displays information about all of the mounted filesystems. If you pass a mount point or partition identifier as a parameter, df displays information about the specified filesystem only. Information includes the device filename, total filesystem size, used space, free space, percentage of disk space used, and mount point. This tool is extremely useful in tracking disk use and in planning disk expansions.

du The df command is very useful for tracking disk use on a partition-by-partition basis, but it's not good for tracking finer-grained disk use. That's where du comes in; it tells you how much disk space each subdirectory in a directory tree uses. This command accepts many options, one of the most useful of which is -max-depth=/7; this option trims the report so you don't see details of subdirectories below a specific depth. For instance, du --max-depth=1 I home will tell you how much disk space your users are consuming in their home directories. (Depending on the permissions users have set, this particular example might work only if it is typed by root.)

stat This command displays information on a file, including the filename, file size, ownership, permissions, three dates (last access, last modification, and last file status change), and some low-level data structures such as the inode number. This information can be useful in determining when files have been used or modified and in performing some low-level file maintenance.

Isof This command lists all the open files on a computer, and it lists information on the user and process that is accessing the files. As such, Isof produces copious output. You'll probably have to pipe the output through less or grep to make sense of it, or you might use various Isof options to trim its output. This command is very useful in finding processes that are using files on removable media you want to unmount but can't because of open files.

uptime This command reports how long the computer has been running. It also displays three load averages, which give you an idea of how much demand there is for CPU time. A load average of 0.0 means no programs are requesting CPU time; 1.0 means the CPU is being used to its fullest; and values above 1.0 mean that the kernel has been rationing CPU time because programs want more CPU time than the system can deliver. Some systems, such as busy servers, run with load averages of well over 1.0, but on others, load averages should be below 1.0 most of the time.

free This command summarizes the system's memory use. The total column displays available memory; used reports memory that's in use; and free summarizes free memory. The most important line is the one labeled -/+ buffers/cache; this line reports memory use by system processes, and so is a good measure of the demand for memory on the system. The Mem line is likely to show very little free memory because this line includes memory that is used by buffers and caches, which are allocated dynamically by Linux to improve disk performance, consuming most memory not being used by programs. The Swap line reports the demand for swap space. If the used entry for this line approaches the total entry, you may need to add memory or swap space to improve performance.

hostname Typed by itself, this command returns the computer's TCP/IP networking hostname. The system administrator may change the hostname by typing a new name after the command.

who This command returns a list of the users who are logged onto the computer. The users command is similar to who, and finger provides additional information.

dmesg This command displays the Linux kernel message buffer. Soon after starting Linux, this buffer contains startup messages, which can be useful in system debugging. As the system runs, the message buffer will accumulate messages on normal operations and the startup messages will be lost.

Tip Because startup messages can be such useful diagnostic tools, you may want to create a startup script that saves these messages as part of the startup process. Debian, Mandrake, and Red Hat all do this by default, storing the results in /var/log/dmesg.

Team LIB

0 0

Post a comment