📄 0305-0307.html
字号:
<HTML>
<HEAD>
<TITLE>Developer.com - Online Reference Library - 0672311623:SAMS TEACH YOURSELF LINUX IN 24 HOURS:Basic System Administration</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!-- ISBN=0672311623 //-->
<!-- TITLE=SAMS TEACH YOURSELF LINUX IN 24 HOURS //-->
<!-- AUTHOR=BILL BALL, STEPHEN SMOOGEN //-->
<!-- PUBLISHER=MACMILLAN //-->
<!-- IMPRINT=SAMS //-->
<!-- PUBLICATION DATE=1998 //-->
<!-- CHAPTER=20 //-->
<!-- PAGES=0291-0312 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0302-0304.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0308-0310.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-305"><P>Page 305</P></A>
<P>
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
</P>
<P>Figure 20.1<BR>
The top command <br>
provides an ongoing <br>
display of your <br>
system.</P>
<P><a href="javascript:displayWindow('images/ch20fg01.jpg', 288, 216)"><img src="images/tn_ch20fg01.jpg"></a><BR>
</P>
<P>
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).
</P>
<P>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.
</P>
<P>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.
</P>
<P>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.
</P>
<A NAME="PAGENUM-306"><P>Page 306</P></A>
<P>The xload command has eight different command-line options, and you can customize
the color of the moving graphic, scale lines, or background.
</P>
<H4><A NAME="ch20_ 16">
Determining How Long Linux Has Been Running with the
uptime and w Commands
</A></H4>
<P>The uptime command shows you how long Linux has been running, how many users are
on, and three system load averages, for example:
</P>
<!-- CODE SNIP //-->
<PRE>
# uptime
12:44am up 8:16, 3 users, load average: 0.11, 0.10, 0.04
</PRE>
<!-- END CODE SNIP //-->
<P>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:
</P>
<!-- CODE //-->
<PRE>
# 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
</PRE>
<!-- END CODE //-->
<P>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.
</P>
<H4><A NAME="ch20_ 17">
Getting Network and Mail Information with the
pppstats and mailstat Commands
</A></H4>
<P>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:
</P>
<!-- CODE //-->
<PRE>
# /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
...
</PRE>
<!-- END CODE //-->
<P>This shows the pppstats command in action after displaying a line of statistics every
five seconds, during startup of a newsreading session.
</P>
<P>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.
</P>
<A NAME="PAGENUM-307"><P>Page 307</P></A>
<!-- CODE SNIP //-->
<PRE>
# mailstat /var/log/maillog
No mail arrived since Nov 19 16:27
</PRE>
<!-- END CODE SNIP //-->
<H4><A NAME="ch20_ 18">
Monitoring Your Serial Ports with the statserial Command
</A></H4>
<P>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:
</P>
<!-- CODE //-->
<PRE>
# 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
</PRE>
<!-- END CODE //-->
<TABLE BGCOLOR=#FFFF99>
<TR><TD>TIME SAVER</TD></TR>
<TR><TD>
<BLOCKQUOTE>
You must be the root operator to use the
statserial program.
</BLOCKQUOTE>
</TD></TR>
</TABLE>
<H3><A NAME="ch20_ 19">
Managing User Access
</A></H3>
<P>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.
</P>
<H4><A NAME="ch20_ 20">
Creating Users with the adduser Command
</A></H4>
<P>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
</P>
<P><CENTER>
<a href="0302-0304.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0308-0310.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -