OpenWindows Advanced User's Guide

Chapter 9 Using the Network

A network is a group of computers set up to communicate with one another. When your machine is part of a network, you have the opportunity to use the resources of other machines on the network while remaining logged in to your own machine. You can log in to other machines or you can execute remote commands affecting other machines from your own workstation.

In this chapter, the following information is provided:

If the machine you're using is not currently attached to a network, the information presented here may not be relevant to your situation. However, it may be valuable for you to at least skim this information to get an overall view of the benefits that networking can provide.

9.1 Networking Concepts

A network connection between machines allows them to transmit information to one another. Networks are often referred to as being local area networks (LANs), which range over small areas, generally less than a few thousand feet; wide area networks (WANs), which can span thousands of miles; or campus area networks (CANs), which are intermediate in size.

A network comprised of a linked group of networks is called an internetwork. For example, your machine may be part of a network within your building and part of an internetwork that connects your local network to similar networks across the country. Since the difference between a network and an internetwork is generally invisible to the user, the term "network" is used in this manual to refer to both networks and internetworks.

Machines attached to a network communicate using a network protocol, or common network language, to ensure that information is transmitted to the appropriate locations. An internetwork protocol, sometimes referred to as a relay, links networks together.

9.2 Logging In Remotely (rlogin)

The rlogin command allows you to log in to other UNIX machines on your network.

To remotely log in to another machine, type:

$ rlogin machinename

where machinename is the name of the remote machine.

If a password prompt appears, type the password for the remote machine and press Return. If your machine name is in the other machine's /etc/hosts.equiv file, the other machine "trusts" your machine name and won't require you to type the password.

$ rlogin lonesome
Password: (type password)
Last login: Mon Jan 6 09:37:55 from blue
Sun Microsystems, Inc.   SunOS 5.1      October 1992
(The following commands done on lonesome.)
$ pwd
/home/keithp
$ logout
Connection closed.
$

9.2.1 rlogin without a Home Directory

In the example above, user keithp logged in to lonesome at the directory /home/keithp, as indicated by the pwd command. When you log in to a machine where you don't have a home directory, rlogin displays a message stating that you have no home directory on the remote machine and logs you in to the root (/) directory of that machine:

$ rlogin fretful
Password:
No directory! Logging in with home=/
Last login: Fri Jan 3 10:21:59 from blue
Sun Microsystems, Inc.    SunOS 5.1      October 1992
(The following commands done on fretful.)
$ pwd
/
$ logout
Connection closed.
$

9.2.2 rlogin as Someone Else

There may be times when you want to log in to a remote machine as someone else. For example, if you're working on someone else's machine (using their username) and you want to log in to your own machine as yourself. The -l option to rlogin allows you to do this. The command syntax is:

rlogin machinename -lusername

For example, the following shows how user keithp on machine blue would log in to machine lonesome as earl:

$ rlogin lonesome -l earl
Password:
Last login: Wed Jan 8 07:12:25 from blue
Sun Microsystems, Inc.    SunOS 5.1      October 1992
(The following commands done on lonesome.)
$ pwd
/home/earl
$ logout
Connection closed.
$

Note that when you log in to a remote machine as someone else, you are placed in that user's home directory.

9.2.3 rlogin to an Unknown Machine

If you try to log in to a remote machine whose name isn't known to your machine, rlogin searches unsuccessfully through the hosts database and then displays a notification as follows:

$ rlogin stranger
stranger: unknown host
$

9.2.4 Aborting an rlogin Connection

Normally you terminate an rlogin connection by typing logout at the end of a work session. If for some reason you can't terminate a session in this manner, you can abort the connection by typing a tilde character followed by a period (~.) at the beginning of a line. The login connection to the remote machine is aborted and you are placed back at your original machine.

If you log in to a series of machines, gaining access to each machine through another machine, and you use ~. to abort the connection to any of the machines in the series, you are returned to your original machine:

$ rlogin dakota
Password:
Last login: Fri Jan 10 09:14:43 from blue
Sun Microsystems, Inc.    SunOS 5.1      October 1992
(The following command done on dakota.)
$ ~.  (You may not see the ~ on the screen.)
Connection closed.
$

If you want to back up to an intermediate rlogin connection, use two tildes followed by a period (~~.) as follows:

$ rlogin lonesome
Password:
Last login: Tue Jan 7 08:12:49 from blue
Sun Microsystems, Inc.    SunOS 5.1      October 1992
(The following command done on lonesome.)
$ rlogin dakota
Password:
Last login: Tue Jan 7 10:17:40 from lonesome
Sun Microsystems, Inc.    SunOS 5.1      October 1992
(The following command done on dakota.)
$ ~~.  (You may not see the ~~ on the screen.)
Connection closed.
$

9.2.5 Suspending an rlogin Connection

When you want to suspend an rlogin connection so you can return to it later, type the tilde character (~) followed by Ctrl-Z. The rlogin connection becomes a stopped process and you are placed back at the machine from which you logged in.

To reactivate the connection, type fg. Alternatively, you can type the percentage sign (%) followed by the process number of the stopped process (the default for %, if no process number is included, is the process most recently suspended).

$ rlogin lonesome
Password:
Last login: Tue Jan 7 08:12:49 from blue
Sun Microsystems, Inc.    SunOS 5.1      October 1992
(The following command done on lonesome.)
 ~^Z  (You may not see the ^Z on the screen.)
Stopped
(The following command done on blue.)
$ pwd
/home/keithp
$ %
rlogin lonesome

(The following command done on lonesome.)
$ logout
Connection closed.
$

Similar to aborting rlogin with ~~., typing two tildes and Ctrl-Z suspends the current rlogin and places you at an intermediate rlogin.

9.2.6 Verifying Your Location (who am i)

After logging in to a variety of remote machines, perhaps under different login names, you might need to verify exactly where you are. Typing who am i displays the name of the machine you're currently logged into as well as your current identity.

Type man rlogin at the command prompt or refer to the man Pages(1): User Commands.

9.3 Copying Files Remotely (rcp)

The rcp command allows you to copy files from one machine to another. It uses the remote machine's /etc/hosts.equiv and /etc/passwd files to determine whether you have unchallenged access privileges. The syntax for rcp is similar to that used for cp.


Note -

To copy subdirectories and their contents from one machine to another, use rcp -r.


9.3.1 Copying from Another Machine to Yours

To copy from a remote machine to your machine, the syntax is:

rcp machinename:source destination

where machinename is the name of the remote machine, source is the name of the file(s) you want to copy, and destination is the path name on your machine where you want the copied file(s) to reside.

The following example illustrates how to copy the file /home/dakota/doc/letter from the remote machine dakota to the /tmp directory on local machine blue:

$ rcp dakota:/home/dakota/doc/letter /tmp
$

You can also combine various abbreviations and syntaxes when using rcp. For example, to copy all of the files ending in .doc from user hank's home directory on remote machine fretful to the current directory on local machine blue, you would type the following:

$ rcp fretful:~hank/*.doc .
$

9.3.2 Copying from Your Machine to Another

To copy from your local machine to a remote machine, the syntax is reversed as follows:

rcp source machinename:destination

where source is the file(s) you want to copy, machinename is the name of the remote machine, and destination is the path name on the remote machine where you want the copied file(s) to reside.

The following example illustrates how you would copy the file austin from your directory ~/usa/texas to the directory ~hank/cities on the remote machine fretful (remember that ~ is your home directory and ~hank is user hank's home directory):

$ rcp ~/usa/texas/austin fretful:~hank/cities
$

For more information on the rcp(1) command and its options, refer to the man Pages(1): User Commands.

9.4 Executing Commands Remotely (rsh)

The rsh command (for remote shell) lets you execute a single command on a remote machine without having to log in formally. It can be a real time-saver when you know you only want to do one thing on the remote machine.

To execute a command on a remote machine, type:

rsh machinename command

The following example shows how you would view the contents of the directory /home/lonesome/guitar on the machine lonesome:

$ rsh lonesome ls /home/lonesome/guitar
collings         gibson          santacruz
fender           martin          taylor
$ 

Similar to the rlogin and rcp commands, rsh uses the remote machine's /etc/hosts.equiv and /etc/passwd files to determine whether you have unchallenged access privileges.

For more information on the rsh(1) command and its options, refer to the man Pages(1): User Commands.

9.5 Viewing User Information (rusers)

The rusers command (for remote users) shows you who's logged on to other machines on your network. Typing the rusers command by itself displays each machine on the network and the user(s) logged in to them, as follows:

$ rusers
aspen          susan
blue           keithp
dakota         sally
farmhouse      elmer
freeway        lindab     johnj     karenm
fretful        hank
lonesome       george
twister        tex
$

Notice that machine freeway has three different users currently logged in.

To display information on a specific remote machine, type the rusers command followed by the name of the machine, as follows:

$ rusers freeway
freeway        lindab     johnj     karenm
$

The -l option to the rusers command provides more detailed information, including user names, machine and terminal names, the time each user logged in, how long each user's been idle (if more than one minute), and the name of the machine that each user logged in from (if any):

$ rusers -l freeway
lindab        freeway:ttyd8     Feb 10 08:12     5:29
johnj         freeway:console   Feb 10 09:16
karenm        freeway:ttyp0     Feb 10 11:56       36
$

You can also use the -l option without providing a machine name.

For more information on the rusers(1) command and its options, refer to the man Pages(1): User Commands.