-->
Page 305
statistical information about how Linux is currently handling your memory, swap file, and processes. The top program also shows how long your system has been running, the status
Figure 20.1
The top command
provides an ongoing
display of your
system.
of your CPU, the size of each process, and more. You'll typically use the top command by running it on a spare console, or separate X11 terminal window (see Figure 20.1).
The top command also has a number of interactive controls, including a help screen, accessed with the question mark or the H key. You can also toggle various modes of the display, such as listing processes by memory usage or limiting the number of processes displayed. This can be helpful if you would like to monitor only the top five processes that require the greatest amount of your system's memory, and it can help you diagnose problems if your computer starts unusual disk or swap file activity.
You can also use top to interactively kill processes, using the K key, or change a process's priority (how much time the CPU devotes to a task) with the R key. The top program has 19 different interactive commands, and you can customize its display by adding or removing different information fields and lengthening or shortening the number of processes. See its manual page for more information.
The xload command, used under X11, provides a running graph of your system's load, instead of the top command's statistics. System loads vary from computer to computer, but you can generally tell when your system is overloaded by inordinate disk activity, as processes are swapped back and forth from your swap file. The xload command can help give you a visual warning if you're running too many programs, and may be especially helpful if you're running X11 on a 8MB or 16MB Linux system.
Page 306
The xload command has eight different command-line options, and you can customize the color of the moving graphic, scale lines, or background.
The uptime command shows you how long Linux has been running, how many users are on, and three system load averages, for example:
# uptime 12:44am up 8:16, 3 users, load average: 0.11, 0.10, 0.04
If this is too little information for you, try the w command, which first shows the same information as the uptime command, and then lists what currently logged-in users are doing:
# w 12:48am up 8:20, 3 users, load average: 0.14, 0.09, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT bball ttyp0 localhost.locald 9:47pm 15.00s 0.38s 0.16s bash bball ttyp2 localhost.locald 12:48am 0.00s 0.16s 0.08s w
The w command gives a little more information, and it is especially helpful if you would like to monitor a busy system with a number of users.
The pppstats command, found under the /usr/sbin directory, will give you a running statistical display on the status and activity of your PPP connection. The information is similar to the output of the ifconfig command. To use the pppstats program, specify the PPP interface (usually 0) on the command after you have connected to your ISP:
# /usr/sbin/pppstats 0 in pack comp uncomp err | out pack comp uncomp ip 24791 93 74 5 0 | 1922 72 54 4 14 78 4 3 0 0 | 80 4 3 0 1 129 2 0 0 0 | 160 3 0 1 2 1169 23 21 1 0 | 842 23 20 2 1 12748 28 27 1 0 | 730 27 18 9 0 9582 18 13 5 0 | 375 13 6 7 0 9399 18 16 2 0 | 268 12 8 4 0 71 3 2 0 0 | 80 4 3 0 1 ...
This shows the pppstats command in action after displaying a line of statistics every five seconds, during startup of a newsreading session.
The mailstat program, a shell script written by S.R. van den Berg, found under the /usr/bin directory, is useful to check whether there's incoming mail, and can be used to generate reports about your mail usage.
Page 307
# mailstat /var/log/maillog No mail arrived since Nov 19 16:27
The statserial program, originally by Jeff Tranter, can be used to show the status of your serial ports, and can be a lifesaver if you need to troubleshoot modems or serial ports. To use statserial, you must specify the device on the program's command line. You can, for example, tell statserial to monitor your modem by specifying its symbolic link:
# ln -s /dev/cua1 /dev/modem # statserial /dev/modem Device: /dev/modem Signal Pin Pin Direction Status Full Name (25) (9) (computer) Name ---- --- --- ---------- ------ ---- FG 1 - - - Frame Ground TxD 2 3 out - Transmit Data RxD 3 2 in - Receive Data RTS 4 7 out 1 Request To Send CTS 5 8 in 1 Clear To Send DSR 6 6 in 0 Data Set Ready GND 7 5 - - Signal Ground DCD 8 1 in 0 Data Carrier Detect DTR 20 4 out 1 Data Terminal Ready RI 22 9 in 0 Ring Indicator
TIME SAVER |
You must be the root operator to use the statserial program. |
One of your main jobs as a sysadmin is to manage the users on your system. This involves creating accounts for new users, assigning home directories, specifying an initial shell for the user, and possibly restricting how much disk space, memory, or how many processes each person can use. This section shows you how to use different command-line programs to manage users. You should also read Hour 22, "Red Hat Tools," if you'd like to see how you can do these and other tasks with graphical utilities while running the X Window System.
One of the first things you should do after installing Linux is to create a user account for yourself. You'll want to do all your work in Linux through this account, and do your system