(Latest Revision: 01/10/2001)

Using Unix Remote (R) Commands

CS 3000 -- Lab Assignment #8

THE .rhosts FILE

In this lab we will experiment with rsh, rcp, and other Unix "r-commands." First of all, if you don't have it already, make a file called .rhosts in your home directory and inside the file put the following lines:
altair.csustan.edu username
capella.csustan.edu username
castor.csustan.edu username
pollux.csustan.edu username
saiph.csustan.edu username
soleil.csustan.edu username
spica.csustan.edu username
regulus.csustan.edu username
rigel.csustan.edu username
vega.csustan.edu username
zaurak.csustan.edu username
Next change each occurrence of "username" to your username. So for example if your username were twalker then you would change the lines above to read:
altair.csustan.edu twalker
capella.csustan.edu twalker
castor.csustan.edu twalker
pollux.csustan.edu twalker
saiph.csustan.edu twalker
soleil.csustan.edu twalker
spica.csustan.edu twalker
regulus.csustan.edu twalker
rigel.csustan.edu twalker
vega.csustan.edu twalker
zaurak.csustan.edu twalker
If you aren't quite sure if you are doing this correctly, ask me about it.

When you have the file correctly configured, save it to disk. This will allow you to use rcp and rsh.

Scan the man page for rhosts now and read the part that explains what you just did.

TRY RSH

Rsh (remote shell) allows you to run a program on some other computer besides the one you are logged into. Check out the man page on rsh.

Pick one of the hosts above that you are not logged into. For example, pick castor if you are not logged into castor. (Please make a random choice.) Do this command:

rsh hostname ps -ef |grep sys

except replace hostname above with the name of the host you picked earlier. Capture the output in a file. The command runs the ps command (process status) on the remote host and (locally) uses grep on the output to do a pattern match for the string "sys." This is a way to check to see if the syslogd program is running on the remote host. The ouput should look something like this:
    root 24195     1  0   Nov 10 ?        0:14 /usr/sbin/syslogd
If you don't see such an output then probably a system administrator needs to restart syslogd on the remote host. System administrators run rsh commands like the example above quite frequently. Doing so provides an alternative to running around and logging in to each of a group of computers to check to see if all is well with them.

HAVE A GO WITH RCP

Rcp (remote copy) allows you to do things like copy a file from some remote computer to your local computer (the one you are logged into), or to copy a file from your local computer to a remote computer. Check out the man page on rcp.

Rcp is especially useful if you want to copy a small number of files and you don't want to go to the trouble of establishing an ftp connection or creating an NFS mount. You might run into a situation like this if you are composing web pages on your favorite local machine and you need to upload a page so you can test to see how it looks when you fetch it from the remote web server.

Try executing the following commands:
cd /tmp
ls
rcp hostname:/etc/motd filename
cat filename
As before, you need to replace hostname with the name of the remote host you picked earlier. Replace filename with some name that is not in use -- one you did notsee when you typed ls above. Capture the output of the commands and append it to your log file. If all went well the cat command should display the little snippet of poetry that is the message of the day on the remote host. (Can you correctly guess the source of the quote? :-)

When finished, clean up by removing the file you created:
rm filename
A COMBINATION

Do these commands:
rsh hostname mkdir FooBar
rcp /etc/motd hostname:FooBar/motd
cd ~/FooBar
cat motd
Since our Network File System (NFS) implementation gives you the same home directory on all the Sun Ultra machines, the effect of this series of commands should be that you make a new subdirectory of your home directory with the rsh command, and then you copy the motd file into the new directory using the rcp command. Then you cd into the directory and look at the file you just put there. Kinda cool, huh?

TRY RLOGIN

Rlogin (remote login) is a Unix program that allows you to login from a local Unix computer to a remote Unix computer. You may be familiar with telnet. Rlogin is a lot like telnet. One advantage of rlogin used on Unix is that it works in combination with the .rhosts file. You can login without giving a password if you are a trusted user listed in the .rhosts file. Look over the man page on rlogin.

Do these commands:
rlogin hostname
whoami
pwd
ls
logout
(Don't forget to substitute for hostname. ) You'll see that you get logged into the remote host as yourself without being asked for a password. This does not work with telnet. When you log out, you just return to your login on your local host with everything as it was before. Rlogin can be very handy if you are doing system administration work, or if you need to move around in your network of machines in order to access resources like perhaps files, printers, or powerful CPU's.

RUP

Rup is a utility for checking all the hosts on the LAN to see if they are up and running alright. System administrators often use such commands as rup to check on their machines. Do the following command:
rup
Append the output to your log file. Do you see any machines that are marked down? Are there any unusual entries? Take a look at the man page for rup, and the man page for uptime. Append an explanation of the meaning of "load average" to your log file.

RUSERS

Rusers will tell you who is logged onto machines around the LAN. Do the following commands:
rusers
rusers -l
Append the output to your log file. Do you see any odd entries? Here is a link to the man page for rusers.

RUPTIME AND RWHO

Ruptime and rwho are the "evil twins" of rup and rusers. It isn't really that they are evil. It's just that they rely on using information from rwho network daemons -- programs that are running all the time constantly sending "are you there" messages to all the other rwho daemons. This wastes a lot of network bandwidth. Rup and rusers don't use network bandwidth until you actually execute them. Ruptime is similar to rup and rwho is similar to rusers. We have disabled ruptime and rwho on the Sun Ultra's, but you can try them out sometime on other Unix systems.

RDIST

Rdist is a program that can place copies of a file on a whole set of machines that you stipulate. Rdist is quite powerful. System administrators can use it to keep software and databases up-to-date and consistent on large networks of computers. Have a look at the man page for rdist. It's beyond the scope of the course to experiment with the actual use of rdist. However it will be good for you to get to know about rdist now.

LAB REPORT

Send your file record to me at this address: tester@alcyone.csustan.edu. Make sure the subject of the e-mail reads: "R-Commands Lab." Put your name at the top of the file before sending. If you worked with a partner be sure to put his or her name there too.