374 lines
5.4 KiB
HTML
374 lines
5.4 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Monitoring Users</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
|
|
REL="HOME"
|
|
TITLE="Linux System Administrators Guide"
|
|
HREF="index.html"><LINK
|
|
REL="UP"
|
|
TITLE="System Monitoring"
|
|
HREF="system-monitoring.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="Filesystem Usage"
|
|
HREF="fs-usage.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Boots And Shutdowns"
|
|
HREF="boots-and-shutdowns.html"></HEAD
|
|
><BODY
|
|
CLASS="SECT1"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
SUMMARY="Header navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>Linux System Administrators Guide: </TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="fs-usage.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
>Chapter 7. System Monitoring</TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="boots-and-shutdowns.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="SECT1"
|
|
><H1
|
|
CLASS="SECT1"
|
|
><A
|
|
NAME="MONITORING-USERS"
|
|
></A
|
|
>7.3. Monitoring Users</H1
|
|
><A
|
|
NAME="AEN3598"
|
|
></A
|
|
><BLOCKQUOTE
|
|
CLASS="BLOCKQUOTE"
|
|
><P
|
|
>Just because you're paranoid doesn't mean they
|
|
AREN'T out to get you... Source Unknown</P
|
|
></BLOCKQUOTE
|
|
><P
|
|
>From time to time there are going to be occasions where you will
|
|
want to know exactly what people are doing on your system. Maybe you
|
|
notice that a lot of RAM is being used, or a lot of CPU activity.
|
|
You are going to want to see who is on the system, what they are
|
|
running, and what kind of resources they are using.</P
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="WHO"
|
|
></A
|
|
>7.3.1. The who command</H2
|
|
><P
|
|
>The easiest way to see who is on the system is to do a
|
|
<B
|
|
CLASS="COMMAND"
|
|
>who</B
|
|
> or <B
|
|
CLASS="COMMAND"
|
|
>w</B
|
|
>. The -->
|
|
<B
|
|
CLASS="COMMAND"
|
|
>who</B
|
|
> is a simple tool that lists out who is logged -->
|
|
on the system and what port or terminal they are logged on at.
|
|
|
|
<TABLE
|
|
BORDER="1"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
><TT
|
|
CLASS="PROMPT"
|
|
>user@server:~></TT
|
|
> <TT
|
|
CLASS="USERINPUT"
|
|
><B
|
|
> who</B
|
|
></TT
|
|
>
|
|
<TT
|
|
CLASS="COMPUTEROUTPUT"
|
|
>bjones pts/0 May 23 09:33
|
|
wally pts/3 May 20 11:35
|
|
aweeks pts/1 May 22 11:03
|
|
aweeks pts/2 May 23 15:04</TT
|
|
></PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="PS-U"
|
|
></A
|
|
>7.3.2. The ps command -again!</H2
|
|
><P
|
|
>In the previous section we can see that user aweeks is logged
|
|
onto both <TT
|
|
CLASS="FILENAME"
|
|
>pts/1</TT
|
|
> and <TT
|
|
CLASS="FILENAME"
|
|
>pts/2</TT
|
|
>,
|
|
but what if we want to see what they are doing? We could to a
|
|
<B
|
|
CLASS="COMMAND"
|
|
>ps -u aweeks</B
|
|
> and get the following output
|
|
|
|
<TABLE
|
|
BORDER="1"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
><TT
|
|
CLASS="PROMPT"
|
|
>user@server:~> </TT
|
|
><TT
|
|
CLASS="USERINPUT"
|
|
><B
|
|
>ps -u aweeks</B
|
|
></TT
|
|
>
|
|
<TT
|
|
CLASS="COMPUTEROUTPUT"
|
|
>
|
|
20876 pts/1 00:00:00 bash
|
|
20904 pts/2 00:00:00 bash
|
|
20951 pts/2 00:00:00 ssh
|
|
21012 pts/1 00:00:00 ps</TT
|
|
></PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
From this we can see that the user is doing a <B
|
|
CLASS="COMMAND"
|
|
>ps</B
|
|
>
|
|
<B
|
|
CLASS="COMMAND"
|
|
>ssh</B
|
|
>.</P
|
|
><P
|
|
>This is a much more consolidated use of the
|
|
<B
|
|
CLASS="COMMAND"
|
|
>ps</B
|
|
> than discussed previously.</P
|
|
><P
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="W"
|
|
></A
|
|
>7.3.3. The w command</H2
|
|
><P
|
|
>Even easier than using the <B
|
|
CLASS="COMMAND"
|
|
>who</B
|
|
> and
|
|
<B
|
|
CLASS="COMMAND"
|
|
>ps -u</B
|
|
> commands is to use the <B
|
|
CLASS="COMMAND"
|
|
>w</B
|
|
>.
|
|
<B
|
|
CLASS="COMMAND"
|
|
>w</B
|
|
> will print out not only who is on the system,
|
|
but also the commands they are running.
|
|
|
|
<TABLE
|
|
BORDER="1"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
><TT
|
|
CLASS="PROMPT"
|
|
>user@server:~> </TT
|
|
><TT
|
|
CLASS="USERINPUT"
|
|
><B
|
|
>w</B
|
|
></TT
|
|
>
|
|
<TT
|
|
CLASS="COMPUTEROUTPUT"
|
|
>aweeks :0 09:32 ?xdm? 30:09 0.02s -:0
|
|
aweeks pts/0 09:33 5:49m 0.00s 0.82s kdeinit: kded
|
|
aweeks pts/2 09:35 8.00s 0.55s 0.36s vi sag-0.9.sgml
|
|
aweeks pts/1 15:03 59.00s 0.03s 0.03s /bin/bash</TT
|
|
></PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
><P
|
|
>From this we can see that I have a <B
|
|
CLASS="COMMAND"
|
|
>kde</B
|
|
> session
|
|
running, I'm working in this document :-), and have another terminal
|
|
open sitting idle at a bash prompt.</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="SKILL"
|
|
></A
|
|
>7.3.4. The skill command</H2
|
|
><P
|
|
> To Be Added</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="NICE"
|
|
></A
|
|
>7.3.5. nice and renice</H2
|
|
><P
|
|
>To Be Added</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
SUMMARY="Footer navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="fs-usage.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
ACCESSKEY="H"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="boots-and-shutdowns.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Filesystem Usage</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="system-monitoring.html"
|
|
ACCESSKEY="U"
|
|
>Up</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Boots And Shutdowns</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |