Obtaining User and System Information

 < Day Day Up > 

tip: If you are not on a network, skip the rest of this chapter

If you are the only user on a system that is not connected to a network, you may want to skip the rest of this chapter. If you are not on a network but are set up to send and receive email, read "Email" on page 69.


This section covers utilities that display 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 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 the 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 3-1 on page 67 summarizes the output of these utilities.

Figure 3-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 

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

Information Displayed

w

who

finger

User login name

x

x

x

Terminal-line identification (tty)

x

x

x

Login day and time

x

 

x

Login date and time

 

x

 

Idle time

x

 

x

What program the user is executing

x

  

Where 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 3-10, the first column shows Alex and Jenny logged in. (Alex is logged in from two locations.) The second column shows the device that each person's terminal, workstation, or terminal emulator is connected to. The third column shows the date and time the person logged in.

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 67) 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 69).

If the output of who scrolls off the screen, you can redirect the output through a pipe 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

security: finger can be a security risk

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


You can use finger to display a list of the users who are logged in on the system. In addition to login names, finger supplies each user's full name along with information about which device the person's terminal is connected to, how recently the user typed something on the keyboard, when the user logged in, and where the user is located (if the device appears in a system database). 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 3-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 68).

Figure 3-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) jenny     Jenny Chen       /2    2:24  Jun  2 05:33 (bravo.example.com) hls       Helen Simpson   */2       2  Jun  2 05:33 (bravo.example.com) 

You can use finger to learn more about a particular individual by specifying that user on the command line. In Figure 3-12, finger displays detailed information about 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.

.plan and .project

Most of the information in Figure 3-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 invisible filenames [page 80].) You may find it helpful to create a .plan file for yourself; it can contain any information you choose, such as your typical schedule, interests, phone number, or address. In a similar manner finger displays the contents of the .project file 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.

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

 $ finger alex Login: alex                             Name: Alex Watson Directory: /home/alex                   Shell: /bin/tcsh 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. 

You can use finger to display a user's login name. For example, you might know that Helen's last name is Simpson but might not guess that her login name 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. ... 

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 3-13 shows that Alex, Jenny, and Scott are logged in. The second column shows the device number that each person'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 each person logged in. The fifth column indicates how long each person has been idle (how much time has elapsed since the user pressed a key on the keyboard). The next two columns give measures of how much computer processor time each person has used during this login session and on the task that is running. The last column shows the command each person is running.

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 3-1 compares the w, who, and finger utilities.

Figure 3-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 

     < Day Day Up > 


    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    ISBN: 131478230
    EAN: N/A
    Year: 2005
    Pages: 213

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