⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 392-394.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Special Edition Using Linux, Fourth Edition:Managing Multiple Processes</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=0789717468//-->

<!--TITLE=Special Edition Using Linux, Fourth Edition//-->

<!--AUTHOR=Jack Tackett//-->

<!--AUTHOR=Jr.//-->

<!--AUTHOR=Steve Burnett//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Que//-->

<!--CHAPTER=19//-->

<!--PAGES=392-394//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="390-392.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="394-397.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P>With these two options, you can get more information about the users now logged in. The headers displayed with the <TT>-H</TT> option are <TT>NAME</TT>, <TT>LINE</TT>, <TT>TIME</TT>, <TT>IDLE</TT>, <TT>PID</TT>, and <TT>COMMENTS</TT>. Table 19.5 explains the terms appearing in the heading.</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 19.5</B> Output Format for the <TT>who</TT> Command

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TH WIDTH="15%" ALIGN="LEFT">Field

<TH WIDTH="85%" ALIGN="LEFT">Description

<TR>

<TD COLSPAN="2"><HR>

<TR>

<TD><TT>NAME</TT>

<TD>Lists the user&#146;s login name.

<TR>

<TD><TT>LINE</TT>

<TD>Lists the line or terminal being used.

<TR>

<TD><TT>TIME</TT>

<TD>Lists the time the user logged in.

<TR>

<TD VALIGN="TOP"><TT>IDLE</TT>

<TD>Lists the hours and minutes since the last activity on that line. A period is displayed if activity occurred within the last minute of system time. If more than 24 hours elapsed since the line was used, the word <TT>old</TT> is displayed.

<TR>

<TD><TT>PID</TT>

<TD>Lists the process ID number of the user&#146;s login shell.

<TR>

<TD VALIGN="TOP"><TT>COMMENT</TT>

<TD>Lists the contents of the comment field if comments have been included in /etc/inittab or if there are network connections.

<TR>

<TD COLSPAN="2"><HR>

</TABLE>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B>You probably won&#146;t see the <TT>COMMENT</TT> field filled in very often in any recent Linux systems. In the old days, processes that let you log in to UNIX (<TT>getty</TT> or <TT>uugetty</TT>) were started directly from entries in the /etc/inittab file and usually listened for login requests from a particular terminal. The <TT>COMMENT</TT> field might identify the location of that terminal and could tell you who was logged in and at what terminal they were sitting. Today, processes that listen for login requests are typically handled by the Service Access Facility and are no longer listed in /etc/inittab.<HR></FONT>

</BLOCKQUOTE>

<P>The following example uses the <TT>-u</TT> and <TT>-H</TT> options and shows the response Linux returns:</P>

<!-- CODE SNIP //-->

<PRE>

$ <B>who -uH</B>

NAME       LINE         TIME       IDLE       PID     COMMENT

root       console  Dec 13 08:00   .          10340

ernie      tty02    Dec 13 10:37   .          11929   Tech-89.2

bkraft     tty03    Dec 13 11:02   0:04        4761   Sales-23.4

jdurum     tty05    Dec 13 09:21   1:07       10426

ernie      ttys7    Dec 11 18:49    old       10770   oreo.coolt.com

$

</PRE>

<!-- END CODE SNIP //-->

<P>You can infer from this listing that the last session associated with ernie is from a network site named oreo.coolt.com and that there hasn&#146;t been any activity in that session in more than 24 hours (which might signal a problem). The session for <TT>root</TT> and the first one for ernie have both been accessed within the last minute. The last activity on the session for bkraft was four minutes ago; it has been one hour and seven minutes since any activity was reported on the session for jdurum.</P>

<P>Also note that this listing includes the PID (process ID number) for the login shell of each user&#146;s session. The next section shows how you can use the PID to further monitor the system.</P>

<P><FONT SIZE="+1"><B>Using the <I>finger</I> Command to Learn More About Who Is on the System

</B></FONT></P>

<P>A command that complements the <TT>who</TT> command is <TT>finger</TT>. To see more information about a specific user, you can enter <TT>finger <I>username</I></TT> (or <TT>finger <I>username&#64;domain</I></TT> if the user is on another computer). For example to see more information on a user named tackett, you would enter this command:</P>

<!-- CODE SNIP //-->

<PRE>

<B>finger tackett</B>

</PRE>

<!-- END CODE SNIP //-->

<P>You would then see the following output:

</P>

<!-- CODE //-->

<PRE>

Login: tackett                          Name: Jack Tackett Jr

Directory: /home/tackett                Shell: /bin/tcsh

Office: 2440 SW Cary Parkway 114        Office Phone: 919 555 1212

Home Phone: 919 555 1212

Never logged in.

Mail last read Fri Jul  3 17:42 1998 (EDT)

Plan:

--------------------------------------------

Jack Tackett, Jr.

In the immortal words of Socrates:

     I drank WHAT?

--------------------------------------------

</PRE>

<!-- END CODE //-->

<P>This output shows the login and real name associate with the specified account. You can also see which shell the user prefers to use, his address, when he last read his e-mail, and when he was last logged in. If he is currently logged on, the <TT>finger</TT> command tells you how long he has been logged on and which program he is currently using. The <TT>finger</TT> command also displays any information a user may have placed in his .plan file in his home directory.</P>

<P>As you can see, the <TT>finger</TT> command displays a lot of information about a user, which could be used by crackers to hack the system. This is why many systems administrators disable the <TT>finger</TT> command so others cannot see this information.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B>If you allow the use of the <TT>finger</TT> command on your system, or if your systems administrator allows it on a system you are using, you can use the <TT>chfn</TT> command to change the information displayed by <TT>finger</TT>. See the related man page (use the <TT>man chfn</TT> command) for more information.<HR></FONT>

</BLOCKQUOTE>

<H4 ALIGN="LEFT"><A NAME="Heading13"></A><FONT COLOR="#000077">Reporting On the Status of Processes with <I>ps</I>

</FONT></H4>

<P>The <TT>ps</TT> (process status) command reports on the status of processes. You can use it to determine which processes are running, whether a process has completed, whether a process is hung or having some difficulty, how long a process has run, the resources a process is using, the relative priority of a process, and the PID (process ID number) needed before you can kill a process. All this information is useful to a user and very useful to a system administrator. Without any options, <TT>ps</TT> lists the PID of each process associated with your current shell. It&#146;s also possible to see a detailed listing of all the processes running on a system.</P>

<P><FONT SIZE="+1"><B>Monitoring Processes with <I>ps</I>

</B></FONT></P>

<P>A common use of the <TT>ps</TT> command is to monitor background jobs and other processes on the system. Because background processes don&#146;t communicate with your screen and keyboard in most cases, you use <TT>ps</TT> to track their progress.</P><P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="390-392.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="394-397.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -