[Return to Library] [Contents] [Previous Chapter] [Next Section] [Next Chapter] [Index] [Help]


10    Obtaining Information About Network Users and Hosts

This chapter describes how to find information about local and remote users and hosts before you begin communication or file transfer tasks. The commands described in this chapter will enable you to:

Note

The commands described in this chapter are, like all TCP/IP operations, subject to the security features on the local and remote hosts. If they do not work as stated here or in the related reference pages, see your system administrator.


[Return to Library] [Contents] [Previous Chapter] [Next Section] [Next Chapter] [Index] [Help]


10.1    Identifying Users on the Local Host

When you log in to a host computer by providing a user name and password, you have a unique identity. To verify this information for your own network connection, you can use a version of the who command called who am i to display the following information about you:

For example, user lennon might enter the who am i command at the system prompt (%) and read the following output:


who am i

lennon     ttyp0      Jul 15 14:17      (walrus)

In this example, user lennon logged in from host walrus at 2:17 in the afternoon of July 15. The line is ttyp0, and walrus is the name for this line, from which the network connection came.

The who am i command can help you keep track of the sessions you have running on your workstation. Some sessions may be remote logins to another host by yourself or by someone with whom you are working. See the who(1) reference page for more information about the who am i command.

To find out if other users are logged in to the same local host, use the who command. In the following example, lennon enters the who command at the prompt of local host london, and learns that three other users are currently logged in to london from different nodes:

london%  who

lennon     ttyp0       Jul 15 08:17       (walrus)
elvis      ttyp2       Jul 15 07:55       (velvet)
burdon     ttyp1       Jul 15 09:02       (animal)
sarjan     ttyp4       Jul 14 16:47       (pepper)

The output from the who command is the same as that from the who am i command.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


10.2    Obtaining Information About Network Users

The finger command and its options enable you to display information about users with accounts on local or remote hosts. The specified host must be running a fingerd daemon server or have the inetd daemon configured to start fingerd. See your system administrator if the finger command does not work as described in the finger(1) reference page.

The finger command has the following syntax:

finger [ [ option... ] [ user... ] [ user@host_name... ] ]

If you use the finger command without specifying an option or a user name, it lists the following information about all users on the local host where you are logged in, if the information is in the /etc/passwd file for a given user:


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


10.2.1    Obtaining Information About a Specific User

If you specify the login name of a user on your local host, the finger command displays more information than if you entered the finger command without specifying a user name. The following additional information about the user is displayed:

The following example shows how to use the finger command to find information about user smith, who has an account on your local host:

finger smith

Login name: smith    (messages off)  In real life: John Smith
Office: LV05-3/T24
Directory: /usr/netd/r2/smith          Shell: /bin/csh
On since Apr  9 16:20:56 on ttypb from wombat.lv5.dec.c
18 seconds Idle Time
Project: book, "Communicating with Network Users"
Plan:
Get information in the following areas:
 network commands
 mailx

In the first line of output, messages off means that user smith has put the mesg n command in his .login file to prevent his terminal from receiving messages from other users through the write or talk commands, which can be distracting.

The preceeding example also displays the contents of the .project file and the .plan file that user smith created in his home directory. The .project file can contain only one line. The .plan file can contain as many lines as the file system allows; finger will print all the lines until the end-of-file (EOF) is reached.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


10.2.2    Obtaining Information About Users on a Remote Host

In the following example, the finger command displays information about users on the remote host boston:


finger @boston

[boston]
Login       Name        TTY Idle    When      Office
amy      Amy Wilson      p0    4 Thu 10:00    345
chang    Peter Chang    *p1 2:58 Thu 10:16    103

The first output line lists the remote host name, boston, and the second line describes the type of information in each column of the remaining output, each line allocated to one user. The asterisk (*) indicates that user chang has put the command, mesg n in his .login file to prevent his terminal from receiving messages from other users through the write or talk commands.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


10.2.3    Obtaining Information About an Individual User on a Remote Host

To display information about user luis on remote host havana use the following finger command:

finger luis@havana

Login name: luis                  In real life: Luis Aguilera
Directory: /users/luis            Shell: /bin/csh
On since May 24 10:16:07 on ttyp2 from :0.0
58 minutes Idle Time
Project: baseball game simulation software
Plan:
Distribute with linked statistics module.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


10.2.4    Customizing Output from the finger Command

There are several options to the finger command that enable you to modify the output according to the data you need. Table 10-1 lists and describes each option.

Table 10-1: Options to the finger Command

Option Description
-b Produces a brief version of output
-f Suppresses display of titles of each field
-h Suppresses printing of users' .project files
-i Displays list of users with idle times
-l Produces long format of output despite other options
-m Assumes that user is an account name
-p Suppresses printing of users' .plan files
-q Displays only users' login and terminal names and login time
-s Produces brief format of output despite other options
-w Produces narrow, brief format of output despite other options

For more information on the finger command, see the finger(1) reference page.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


10.3    Obtaining Information about Remote Hosts and Users

Before you send messages or transfer files over the network using the commands described in this book, you should know whether or not the recipient host is currently online. To do this, use the ruptime command which works for hosts that are running the rwhod daemon on the local network.

The ruptime command displays the following information:

The syntax of the ruptime command is:

ruptime [ [ option... ] [ sort_option ] ]

If you use the ruptime command without options, a status report about the hosts on your local network, sorted alphabetically by host name, is displayed. For example:

ruptime

apple     up 102+05:07   4 users,  load 0.09, 0.04, 0.04
byblos    up   3+03:17,  3 users,  load 0.08, 0.07, 0.04
carpal    up      2:28,  0 users,  load 7.01, 5.02, 3.03
dull    down   9+21:59
eager   down  23+22:45
foobar    up   3+01:44,  9 users,  load 0.01, 0.02, 0.03
garlic    up  14+01:35,  1 user,   load 0.06, 0.12, 0.11
hiccup    up  4+22:14,  19 users,  load 6.37, 3.90, 2.71
jackal    up 13+10:32,  26 users,  load 0.70, 0.92, 0.95
starry    up 16+21:08,   1 user,   load 0.22, 0.14, 0.07
travel    up 13+23:44,   7 users,  load 1.01, 1.19, 0.5
trekky  down 23+03:53
tribbl    up  8+21:43,   0 users,  load 0.00, 0.00, 0.00
trubbl    up 14+02:34,   0 users,  load 0.00, 0.00, 0.00
tunnel  down 14+02:34
warp9     up  8+01:24,   9 users,  load 0.01, 0.02, 0.03

Often, you need to determine only whether a single host is currently online. To do this, enter the ruptime command with the host name, as shown in the following example, for host trekky:


ruptime trekky

trekky    down 23+03:53

This output shows that host trekky is not currently online.

You can also determine whether a host is online by using the ping command described in Section 10.5; ping works for any host in a TCP/IP network configuration.

If you plan to run commands on a remote host (as described in Chapter 13), use the ruptime command with the -l option to determine whether the host resources will be adequate. This command sorts the hosts by load average in descending order. The following example shows partial output from the ruptime -l command:


ruptime -l

carpal   up      2:28,   0 users,   load 7.01, 5.02, 3.03
hiccup   up  4+22:14,   19 users,   load 6.37, 3.90, 2.71
travel   up 13+23:44,    7 users,   load 1.01, 1.19, 0.5
jackal   up 13+10:32,   26 users,   load 0.70, 0.92, 0.95

.
.
.

In this example, usage is low on all hosts except carpal and hiccup. Therefore, you may decide to remotely log in to either travel or jackal, if either host is suitable for your purpose. If you need to use a remote host for a long period of time, you should know the total number of users there, not just the number whose sessions have been active for an hour or longer. Use the ruptime command with the -a option to display the total number of users on a remote host. The following two examples use the ruptime -a command to determine the total number of users first on host travel, and then on host jackal:


ruptime -a travel

travel   up 13+23:44,    32 users,   load 1.01, 1.19, 0.5


ruptime -a jackal

jackal   up 13+10:32,    29 users,   load 0.70, 0.92, 0.95

From the results of the ruptime command using the -a and -l options (in the preceding example), you can determine that both hosts have nearly the same number of users, but the current usage on host travel is calculated from only the 7 (from a total of 32) users whose sessions have been active for an hour or longer. By contrast, usage on host jackal is less, but is calculated from 26 of the total of 29 users. You could conclude that, over a period of time, usage on host travel may increase as more users log in, but that usage on host jackal may either decrease or stay nearly the same, because most of its users are already logged in.

The remaining options (except for -r) sort by different output fields, and in descending alphabetical order. To reverse this order, put the -r option after the other option on the command line. You should not combine other ruptime command options; if you do, only the last option on the command line will be used. Table 10-2 describes each option.

Table 10-2: Options to the ruptime Command

Option Description
-a Provides information for all users, including those whose sessions have been idle for an hour or longer
-l Sorts output by load average over 5-, 10-, and 15-minute intervals
-r Reverses the sort order
-t Sorts output by length of time host is online
-u Sorts output by number of users

For more information, see the ruptime(1) reference page.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


10.4    Obtaining Information About Users on Remote Hosts

Before using a command that sends a message or transfers a file, you often need to know if the recipient user is logged in. To determine whether a user is logged in to a remote host on the local network, you can use the rwho command, specifying the name of one or more users. The rwho command operates only for hosts running the rwhod daemon. See your system administrator if necessary.

The rwho command displays the following information:

The rwho command has the following syntax:

rwho [ [ -a ] [ user... ] ]

Without options, the rwho command lists all users currently logged in to hosts on the local network, except those who have been idle for an hour or longer. A typical local network has several dozen users, so you should specify only the users about whom you need information.

Although the -a option displays all users, including those idle for more than an hour, you can still use it while specifying only certain users. This enables you to determine whether or not a remote user is logged in, regardless of whether that user has been inactive for an hour or longer. The following example uses rwho with the -a option to determine this information for users wally, becky, and smith:


rwho -a wally becky smith

becky   cygnus:pts0     Jan 17 11:20 :12
smith   aquila:ttyp0    Jan 15 09:52 :22
wally   lyra:pts7       Jan 17 13:15 1:32
wally   lyra:pts8       Jan 17 14:15 1:01

As shown, the output from the rwho command displays in alphabetical order by user name, then by host name. The amount of idle time greater than one hour is shown in the last column, after the starting time and date of each session. Without the -a option, the information for user wally would not have displayed.

For more information on the rwho command, see the rwho(1) reference page.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Chapter] [Index] [Help]


10.5    Determining Whether a Remote Host Is Online

The ping command is used by system administrators to fix network transmission problems and works for any host configured in a TCP/IP network. As a network user, you can use it to determine whether a remote host is currently online. For example, to determine whether remote host moon is online, enter the ping command at your local system prompt. The output, which verifies that the remote host is online, will continue to display until you press Ctrl/c, as shown in the following example:

ping moon
PING moon (130.180.4.108): 56 data bytes
64 bytes from 130.180.4.108: icmp_seq=0 ttl=255 time=42 ms
64 bytes from 130.180.4.108: icmp_seq=1 ttl=255 time=0 ms
64 bytes from 130.180.4.108: icmp_seq=2 ttl=255 time=0 ms
64 bytes from 130.180.4.108: icmp_seq=3 ttl=255 time=0 ms
\*(KbCtrl/c\*(Ke
----moon PING Statistics----
9 packets transmitted, 9 packets received, 0% packet loss
round-trip (ms) min/avg/max = 0/4/42 ms