For this exercise you will need to open up a "terminal" or "console" window. You should be able to open a terminal by right clicking on your desktop. In the terminal window, type the commands given below at the > prompt.
You all know how to log in on the Science and Engineering Node Service (SENS) Unix machines. You simply type your username and password at the main prompt. But what you may not know is that you can log onto other machines, from the machine at which you happen to be sitting, using the rlogin command. This is one of the beauties (and frustrations) of Unix. It doesn't matter where you are sitting, you can work on any machine.
The rlogin command syntax is: rlogin [options] host
The rlogin command, which stands for remote login, lets you connect your local host to a remote host. If you want to remotely log into ubunix, for example you can do something like this:
> rlogin ubunix.acsu.buffalo.edu
you will then be prompted for your password. The system will probably assume that you have the same username as the name which you are using for the local machine. If not, it will prompt you for your username. The computer ubunix is adminstrated by CIT, so you will want to use your CIT password to get in. This is the password you received when you first registered for classes.
To logout of the remote machine, simply type:
exit
Exercise
Remotely log onto ubunix.acsu.buffalo.edu. Type the command:
who
Your name and some of our classmate should appear on the userlist, if you are doing this the same time as everyone else in class. Stay logged into ubunix for the next exercise.
We will try a few easy commands to get started. Please try working the examples shown in blue text. Note that the UNIX prompt will be represented throughout by a ">". The prompt can vary (and is changable) but most introductions assume a prompt of "$" or "%".
We'll begin with the date command. It displays what the UNIX operating system thinks is the current date and time.
> date
Thu Jun 19 15:29:19 NDT 1997
Perhaps not very useful. Lets go back to the who command to see how you can change the output of a command. The who command tells you who is currently using the system.
> who
jmorris ttyq7 Jun 19 09:34
michael ttyp4 Jun 04 16:01
mike ttyp6 May 05 11:07
This list is sometimes quite long, if you are logged on to a central machine like those used for ubunix. A helpful hint here is to use the sort and more commands. sort will simply alphabatize the entries. If the output of a command fills up more than one screen, some information may be lost. Thus, we use the more command to halt output after the screen has filled. (Once in "more mode" you can go from screen to screen using the space bar; a new line at a time using the enter key or quit by typing q.)
(Note: the program pg could also be used to display the contents of a file with more than one screenful worth of text, one screen at a time. In this case, use RETURN to show the next page and "q" to quit.)
Ready to try it? I don't think so. If you try and use the commands all at the same time like, say:
> who sort more
you will get an error message. What you need here is a | (a pipe, sometimes called "vertical bar"). The pipe can usually be found over the back slash on PC keyboards. This will allow us to use "piping" or, to be more technical, take the output of one command and direct it to the input of another command. Try the following to get your nicely sorted list of who is on the system:
> who|sort|more
It may seem silly to have to ask the computer who you are. But in the world of unix where the network is the computer, this command can be very useful:
> who am i
jmorris ttypa Jun 19 09:48
Don't I need a pipe here?
No. "am i" are arguments (or options) to the who command. Said differently, they are not commands to themselves (like sort or more above), they alter the way the who command works. You will find that most commands have many, and sometimes, an overwhelming number of options.
You can close the ubunix window now by typing
>exit
The UNIX Programmer's Manual itself is kept on the system. It is possible to get the documentation for any given command by using the man command. For example, to access the manual page for the who command use:
>man who
who(1) who(1)
NAME
who - Identifies users currently logged in
... (rest of entry)
>
The online manual is extremely opaque at first, so don't get frustrated. There will be a million options, but at the bottom of the manual there are often example usages, which are typically the most helpful.
When you are not sure of the exact name of a command, use apropos:
> apropos keyword
will give you the commands with keyword in their manual page header. For example, try typing
> apropos copy
Now try the apropos command and get the result page by page