Obtaining User and System Information


This section covers utilities that provide information about who is using the system, what those users are doing, and how the system is running. To find out who is using the local system, you can employ one of several utilities that vary in the details they provide and the options they support. The oldest utility, who, produces a list of users who are logged in on the local system, the device each person is using, and the time each person logged in.

The w and finger utilities show more detail, such as each user's full name and the command line each user is running. You can use the finger utility to retrieve information about users on remote systems if your computer is attached to a network. Table 5-1 on page 150 summarizes the output of these utilities.

Table 5-1. Comparison of w, who, and finger

Information displayed

w

who

finger

Username

x

x

x

Terminal-line identification (tty)

x

x

x

Login day and time

x

  

Login date and time

 

x

x

Idle time

x

 

x

Program the user is executing

x

  

Location the user logged in from

  

x

CPU time used

x

  

Full name (or other information from /etc/passwd)

  

x

User-supplied vanity information

  

x

System uptime and load average

x

  


who: Lists Users on the System

The who utility displays a list of users who are logged in. In Figure 5-10 the first column that who displays shows that Alex and Jenny are logged in. (Alex is logged in from two locations.) The second column shows the device that each user's terminal, workstation, or terminal emulator is connected to. The third column shows the date and time the user logged in. An optional fourth column shows (in parentheses) the name of the system that a remote user logged in from; this column does not appear in Figure 5-10.

Figure 5-10. who lists who is logged in

$ who root       console       Mar 27 05:00 alex       pts/4         Mar 27 12:23 alex       pts/5         Mar 27 12:33 jenny      pts/7         Mar 26 08:45

The information that who displays is useful when you want to communicate with a user at your installation. When the user is logged in, you can use write (page 150) to establish communication immediately. If who does not list the user or if you do not need to communicate immediately, you can send email to that person (page 152).

If the output of who scrolls off the screen, you can redirect the output through a pipe (|, page 136) so that it becomes the input to less, which displays the output one page at a time. You can also use a pipe to redirect the output through grep to look for a specific name.

If you need to find out which terminal you are using or what time you logged in, you can use the command who am i:

$ who am i alex       pts/5        Mar 27 12:33


finger: Lists Users on the System

You can use finger to display a list of the users who are logged in on the system. In addition to usernames, finger supplies each user's full name along with information about which device the user's terminal is connected to, how recently the user typed something on the keyboard, when the user logged in, and what contact information is available. If the user has logged in over the network, the name of the remote system is shown as the user's location. For example, in Figure 5-11 jenny and hls are logged in from the remote system named bravo. The asterisk (*) in front of the name of Helen's device (TTY) indicates that she has blocked others from sending messages directly to her terminal (refer to "mesg: Denies or Accepts Messages" on page 151).

Figure 5-11. finger I: lists who is logged in

$ finger Login    Name            Tty   Idle  Login Time   Office  Office Phone root     root             1    1:35  May 24 08:38 alex     Alex Watson     /0          Jun  7 12:46 (:0) alex     Alex Watson     /1      19  Jun  7 12:47 (:0) jenn     Jenny Chen      /2    2:24  Jun  2 05:33 (bravo.example.com) hls      Helen Simpson  */2       2  Jun  2 05:33 (bravo.example.com)

Security: finger can be a security risk

On systems where security is a concern, the system administrator may disable finger. This utility can reveal information that can help a malicious user break into a system.


You can also use finger to learn more about an individual by specifying the name of that user on the command line. In Figure 5-12, finger displays detailed information about the user named Alex. Alex is logged in and actively using one of his terminals (pts/1); he has not used his other terminal (pts/0) for 5 minutes and 52 seconds. You also learn from finger that if you want to set up a meeting with Alex, you should contact Jenny at extension 1693.

Figure 5-12. finger II: lists details about one user

$ finger alex Login: alex                             Name: Alex Watson Directory: /home/alex                   Shell: /bin/bash On since Wed Jun  7 12:46 (PDT) on pts/0 from :0    5 minutes 52 seconds idle On since Wed Jun  7 12:47 (PDT) on pts/1 from bravo Last login Wed Jun  7 12:47 (PDT) on 1 from bravo New mail received Wed Jun  7 13:16 2006 (PDT)      Unread since Fri May 26 15:32 2006 (PDT) Plan: I will be at a conference in Hawaii all next week.  If you need to see me, contact Jenny Chen, x1693.

.plan and .project


Most of the information in Figure 5-12 was collected by finger from system files. The information shown after the heading Plan:, however, was supplied by Alex. The finger utility searched for a file named .plan in Alex's home directory and displayed its contents. (Filenames that begin with a period, such as .plan, are not normally listed by ls and are called hidden filenames [page 170].) You may find it helpful to create a .plan file for yourself; it can contain any information you choose, such as your schedule, interests, phone number, or address. In a similar manner, finger displays the contents of the .project and .pgpkey files in your home directory. If Alex had not been logged in, finger would have reported only his user information, the last time he logged in, the last time he read his email, and his plan.

You can also use finger to display a user's username. For example, on a system with a user named Helen Simpson, you might know that Helen's last name is Simpson but might not guess that her username is hls. The finger utility, which is not case sensitive, can search for information on Helen using her first or last name. The following commands find the information you seek as well as information on other users whose names are Helen or Simpson:

$ finger HELEN Login: hls                               Name: Helen Simpson. ... $ finger simpson Login: hls                               Name: Helen Simpson. ...


See page 360 for information about using finger over a network.

w: Lists Users on the System

The w utility displays a list of the users who are logged in. As discussed in the section on who, the information that w displays is useful when you want to communicate with someone at your installation.

The first column in Figure 5-13 shows that Alex, Jenny, and Scott are logged in. The second column shows the designation of the device that each user's terminal is connected to. The third column shows the system that a remote user is logged in from. The fourth column shows the time when each user logged in. The fifth column indicates how long each user has been idle (how much time has elapsed since the user pressed a key on the keyboard). The next two columns identify how much computer processor time each user has used during this login session and on the task that is running. The last column shows the command each user is running.

Figure 5-13. The w utility

$ w   8:20am  up 4 days,  2:28, 3 users,  load average: 0.04, 0.04, 0.00 USER     TTY      FROM         LOGIN@   IDLE   JCPU   PCPU   WHAT alex     pts/4    :0           5:55am  13:45  0.15s   0.07s  w alex     pts/5    :0           5:55am     27  2:55    1:01   bash jenny    pts/7    bravo        5:56am  13:44  0.51s     30s  vim 3.txt scott    pts/12   bravo        7:17pm         1.00s   0:14s  run_bdgt

The first line that the w utility displays includes the time of day, the period of time the computer has been running (in days, hours, and minutes), the number of users logged in, and the load average (how busy the system is). The three load average numbers represent the number of jobs waiting to run, averaged over the past 1, 5, and 15 minutes. Use the uptime utility to display just this line. Table 5-1 compares the w, who, and finger utilities.




A Practical Guide to Red Hat Linux
A Practical Guide to Red HatВ® LinuxВ®: Fedoraв„ў Core and Red Hat Enterprise Linux (3rd Edition)
ISBN: 0132280272
EAN: 2147483647
Year: 2006
Pages: 383

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net