📄 yolinux tutorial linux system configuration and administration.mht
字号:
ml"><B>Installing=20
a new kernel RPM</B></A>=20
<LI><A =
href=3D"http://www.yolinux.com/TUTORIALS/index.html"><B>YoLinux=20
Tutorials Index</B></A> </LI></UL><A name=3DMONITOR></A>
<P>
<HR SIZE=3D5>
<TABLE cellSpacing=3D0 cellPadding=3D2 width=3D"100%" border=3D0>
<TBODY>
<TR bgColor=3D#ffcc33>
<TD><B><BIG>Monitoring the =
system:</BIG></B></TD></TR></TBODY></TABLE>
<P><B>Basic command line:</B>=20
<DL>
<DD>
<TABLE>
<TBODY>
<TR>
<TD><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dpstree">=
pstree</A>=20
</TD>
<TD>Processes and parent-child relationships</TD></TR>
<TR>
<TD><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dtop">top=
</A>=20
</TD>
<TD>Show top processes</TD></TR>
<TR>
<TD><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dps">ps=20
-auxw</A> </TD>
<TD>process status</TD></TR>
<TR>
<TD><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dvmstat">=
vmstat</A>=20
</TD>
<TD>Monitor virtual memory</TD></TR>
<TR>
<TD><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dfree">fr=
ee</A>=20
</TD>
<TD>Display amount of free and used memory in the system. =
(Also:=20
<TT>cat /proc/meminfo</TT>)</TD></TR>
<TR>
<TD><A =
href=3D"http://web.hexapodia.org/~adi/pmap.c">pmap</A> </TD>
<TD>Display/examine memory map and libraries (so). Usage: =
<TT>pmap=20
<I>pid</I></TT></TD></TR>
<TR>
<TD>cat /proc/sys/vm/freepages</TD>
<TD>Display virtual memory "free pages". <BR>One may=20
increase/decrease this limit: <TT>echo 300 400 500 >=20
/proc/sys/vm/freepages</TT></TD></TR>
<TR>
<TD><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Duname">u=
name=20
-a</A> </TD>
<TD>print system information</TD></TR>
<TR>
<TD>cat /proc/version </TD>
<TD>Display Linux kernel version in use.</TD></TR>
<TR>
<TD>cat /etc/redhat-release </TD>
<TD>Display Red Hat Linux Release. (also=20
<TT>/etc/issue</TT>)</TD></TR>
<TR>
<TD><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Duptime">=
uptime</A>=20
</TD>
<TD>Tell how long the system has been running. Also number =
of=20
users and system's load average.</TD></TR>
<TR>
<TD><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dw">w</A>=
=20
</TD>
<TD>Show who is logged on and what they are doing.</TD></TR>
<TR>
<TD><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dlsmod">/=
sbin/lsmod</A>=20
</TD>
<TD>List all currently loaded kernel modules.<BR>Same as =
<TT>cat=20
/proc/modules</TT></TD></TR>
<TR>
<TD><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Drunlevel=
">/sbin/runlevel</A>=20
</TD>
<TD>Displays the system's current runlevel.</TD></TR>
<TR>
<TD><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dhostname=
">hostname</A>=20
</TD>
<TD>Displays/changes the system's node name. (Must also =
manually=20
change hostname setting in =
<TT>/etc/sysconfig/network</TT>.=20
Command will change entry in =
<TT>/etc/hosts</TT>)</TD></TR>
<TR>
<TD vAlign=3Dtop>service</TD>
<TD vAlign=3Dtop>Red Hat/Fedora command to display status of =
system=20
services.<BR>Example: <TT>service =
--status-all</TT><BR>Help:=20
<TT>service =
--help</TT></TD></TR></TBODY></TABLE></DD></DL>
<P><B>GUI/Graphical:</B>=20
<DL>
<DD>
<TABLE>
<TBODY>
<TR>
<TD><A=20
=
href=3D"http://freshmeat.net/projects/gnome-system-monitor/">gnome-system=
-monitor</A>=20
</TD>
<TD>Operating system monitor and usage graphing.</TD></TR>
<TR>
<TD><A=20
=
href=3D"http://web.wt.net/~billw/gkrellm/gkrellm.html">gkrellm</A>=20
</TD>
<TD>Graphical system monitor. (Additional RPM package:=20
gkrellm)</TD></TR>
<TR>
<TD><A href=3D"http://user.tninet.se/~uhu537u/">ps3</A> =
</TD>
<TD>3D load meter. Very cool 3-D graphics.</TD></TR>
<TR>
<TD><A href=3D"http://xosview.sourceforge.net/">xosview</A> =
</TD>
<TD>Operating system monitor: load, memory, swap, net, disk, =
...</TD></TR></TBODY></TABLE></DD></DL>
<P><B>List of tools:</B>=20
<UL>
<LI><A=20
=
href=3D"http://www.ibiblio.org/pub/Linux/system/status/!INDEX.html">tools=
=20
for finding the status of your system</A> </LI></UL><A =
name=3DPROCESSES></A>
<P>
<HR SIZE=3D5>
<TABLE cellSpacing=3D0 cellPadding=3D2 width=3D"100%" border=3D0>
<TBODY>
<TR bgColor=3D#ffcc33>
<TD><B><BIG>Process =
Management:</BIG></B></TD></TR></TBODY></TABLE>
<P>The basic monitoring commands such as <TT>pstree</TT> and =
<TT>ps=20
-auxw</TT> and <TT>top</TT> will inform you of the processes =
running on=20
your system. Sometimes a process must be terminated. To terminate =
a=20
process:=20
<OL>
<LI>Identify the process:=20
<UL>
<LI><TT>pstree -p</TT> <BR>OR=20
<LI><TT>ps -auxw</TT> <BR>OR=20
<LI><TT>top</TT> </LI></UL>
<LI>Kill the process:=20
<UL>
<LI><TT>kill <<I>process-id-number</I>></TT>=20
<LI><TT>killall <<I>command-name</I>></TT> =
</LI></UL></LI></OL>
<P>This will perform an orderly shutdown of the process. If it =
hangs give=20
a stronger signal with: <TT>kill -9 =
<<I>process-id-number</I>></TT>.=20
This method is not as sanitary and thus less preferred.=20
<P>A signal may be given to the process. The program must be =
programmed to=20
handle the given signal. See <TT>/usr/include/bits/signum.h</TT> =
for a=20
full list. For example, to restart a process after updating it's=20
configuration file, issue the command <TT>kill -HUP=20
<<I>process-id-number</I>></TT>=20
<P>In the previous example, the <B>HUP</B> signal was sent to the =
process.=20
The software was written to trap for the signal so that it could =
respond=20
to it. If the software (command) is not written to respond to a =
particular=20
signal, then the sending of the signal to the process is futile.=20
<P>Identify all known signals: <TT><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dfuser">f=
user</A>=20
-l</TT>=20
<P>
<H4>Process Management GUI Tools:</H4>
<UL>
<LI><A href=3D"http://xosview.sourceforge.net/">xosview</A>: =
Oldie but=20
goodie.=20
<LI>gnome-system-monitor=20
<LI>ksysguard (comes with SuSE)=20
<LI><A =
href=3D"http://www.student.nada.kth.se/~f91-men/qps/">QPS</A> (See=20
below) </LI></UL>
<P><B>QPS: </B>
<DL>
<DD>Also see the <A=20
href=3D"http://www.student.nada.kth.se/~f91-men/qps/">GUI tool =
QPS</A>.=20
(Handles MOSIX cluster) This tool is outstanding for monitoring, =
adjusting nice values (priorities), issue signals to the =
process, view=20
files the process is using, the memory, environmnet variables =
and=20
sockets the process is using. RPM available from this site. It =
is so=20
simple to use, no instructions are necessary. It can monitor a =
program=20
to make sure it isn't doing something bad. It is also reverse =
engineer=20
what applications are doing and the environments under which =
they run. I=20
love this tool!!=20
<P>
<UL>
<LI><A =
href=3D"http://www.student.nada.kth.se/~f91-men/qps/">QPS home=20
page: 1.9.7</A> [<A=20
href=3D"ftp://ptah.lnf.kth.se/pub/qps/">Downloads</A>]=20
<LI><A href=3D"http://qps.kldp.net/">QPS: newer version =
1.9.8-1.9.14</A>=20
- [<A=20
=
href=3D"http://rpmseek.com/rpm-pl/qps.html?hl=3Dcom&cx=3D857:Q:0">Dow=
nload=20
RPMs for Fedora 4, 5, SuSE, Mandriva</A>] <BR>(SuSE version =
9.3 ships=20
with a brokern QPS. Download a working version at link above.) =
</LI></UL>
<P>Note: The RPM provided was compiled for RedHat 7.x. For =
RedHat 8.0+=20
one must install the appropriate QT library RPMs to satisfy=20
dependencies: <PRE> rpm -ivh qt2-2.3.1-8.i386.rpm =
qt2-Xt-2.3.1-8.i386.rpm qt2-devel-2.3.1-8.i386.rpm =
qt2-static-2.3.1-8.i386.rpm
</PRE>Then install qps: <TT>rpm -ivh qps-1.9.7-5.i386.rpm</TT>=20
<P>Note Fedora Core 3: <TT>rpm -ivh qt2-2.3.1-8.i386.rpm=20
qps-1.9.7-5.i386.rpm</TT> <BR>These older RH 8.0 and 7 binary =
release=20
rpms even work on my AMD64 Fedora Core 3 x86_64 OS system.=20
<P>Configuring QPS to run applications against a process: Select =
"Command" + "Edit Commands..." + "Add..."=20
<UL>
<LI>Description: GDB <BR>Command Line: <TT>xterm -T "GDB %C" =
-e gdb -d=20
/<I>directory-where-source-code-is-located</I> --pid=3D%p</TT> =
<LI>Description: gdb <BR>Command Line: <TT>xterm -T "gdb %c =
(%p)" -e=20
gdb /proc/%p/exe %p &</TT> <BR>(As issued in RPM) <BR><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dgdb">gdb=
=20
man page</A>=20
<LI>Description: strace <BR>Command Line: <TT>xterm -T "strace =
%c=20
(%p)" -e sh -c 'strace -f -p%p; sleep 10000'&</TT> =
<BR>(show=20
process system calls and signals. Try it with the process qps =
itself.)=20
<BR>Show output written by process: <BR><TT>xterm -T "strace =
%c (%p)"=20
-e sh -c 'strace -f -q -e trace=3Dwrite -p%p; sleep =
10000'&</TT>=20
<BR><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dstrace">=
strace=20
man page</A>=20
<LI>Description: truss (Solaris command) <BR>Command Line: =
<TT>xterm=20
-T "truss %C (%p) -e sh -c 'truss -f -p %p; sleep =
1000'&</TT>=20
</LI></UL></DD></DL>
<P><B>IPCs: Semaphores, Shared Memory and Queues</B>=20
<P>
<DL>
<DD>Note that some processes may use Linux InterProcess =
Communication or=20
IPC (semaphores, shared memory or queues) which may need to be =
cleaned=20
up manually:=20
<OL>
<LI>Identify the semaphores: <TT><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dipcs">ip=
cs</A></TT>=20
<BR><TT>ipcs -q</TT> List share queues. <BR><TT>ipcs -m</TT> =
Shared=20
memory. <BR><TT>ipcs -s</TT> List Semaphores.=20
<LI>Remove the semaphores: <TT><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dipcrm">i=
pcrm</A>=20
-s <<I>ipcs id</I>></TT> </LI></OL>
<P>Example: If you are running Apache, you may see the =
following:=20
<DL>
<DD><PRE><B>[root@node DIR]#</B> ipcs -m =20
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status =20
0x00000000 341504 nobody 600 46084 27 dest =20
</PRE></DD></DL></DD></DL>
<P><B>lsof - Processes attached to open files or open network =
ports:</B>=20
<DL>
<DD>The command <TT><A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dlsof">ls=
of</A></TT>=20
shows a list of processes attached to open files or network =
ports.=20
<UL>
<LI>List processes attached to a given file: <TT>lsof=20
<I>filename</I></TT>:=20
<DL>
<DD><PRE><B>[root@node DIR]#</B> lsof =
/var/log/mailman/qrunner
python 18538 mailman 4u REG 3,5 657 486746 =
/var/log/mailman/qrunner
python 18578 mailman 6u REG 3,5 657 486746 =
/var/log/mailman/qrunner
python 18579 mailman 6u REG 3,5 657 486746 =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -