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:
Learn about your own network connection (who am i
command,
Section 10.1)
Determine who is currently logged in to the local system and
from where they are logged in (who
command,
Section 10.1)
Find additional information about another user, if available;
for example, full name, office location, phone number, projects, or plans
(finger
command,
Section 10.2.1)
Determine whether a user can be reached using either the
talk
or
write
commands (finger
command,
Section 10.2.1
and
Section 10.2.2)
Analyze and sort information about remote host usage (ruptime
command,
Section 10.3)
Determine who is currently logged in to a remote host (rwho
command,
Section 10.4)
Determine whether a remote host is on line (ping
command,
Section 10.5)
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.
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:
Login name
Terminal name (line)
Time of login
Computer from which the network connection came
For example, user
lennon
might enter the
who am i
command at the system prompt (%
) and
read the following output:
%
who -M 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 -M
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.
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:
Login name
Full name
Terminal line name and whether it can receive messages from
other users through
write
(see
Section 11.8)
or
talk
(see
Section 11.9)
Idle time
Login time
User's office location
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:
User's home directory and login shell
Contents (if any) of the
.plan
and
.project
files in the user's home directory
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:
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.
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.
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.
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.
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 on line.
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:
Host name
On line status (up
for on line or
down
for off line)
The length of time the host has been on line (or off line) in days, if more than one whole day, hours and minutes
The number of users currently logged in to the host (optionally including those whose sessions have been idle for an hour or longer)
Load average statistics in 5-, 10-, and 15-minute intervals
prior to the
ruptime
request
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.
In this report the length of time the host has
been on line (or off line) is shown in the format
hours;minutes.
If a plus sign (+
) is included, the time exceeds
one day (24 hours).
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
on line.
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
on line.
You can also determine whether a host is on line 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 log in remotely
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 in the last
hour.
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 become active, but that usage on host
jackal
may either decrease or stay nearly the same, because most of its users are
currently active.
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 on line |
-u |
Sorts output by number of users |
For more information, see the
ruptime
(1)
reference page.
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:
User name
Host name
Start date and time
Number of minutes a user's session has been inactive.
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.
Because the
-a
flag was
specified, the output also includes users idle for more than one hour.
Without
the
-a
flag, the information for user
wally
would not have displayed.
For more information on the
rwho
command, see the
rwho
(1)
reference page.
10.5 Determining Whether a Remote Host Is On Line
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 on line.
For example, to determine whether remote
host
moon
is on line, enter the
ping
command at your local system prompt.
The output, which verifies that the remote
host is on line, 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
[Ctrl/C]
----moon PING Statistics---- 4 packets transmitted, 4 packets received, 0% packet loss round-trip (ms) min/avg/max = 0/11/42 ms