Whilst ProgSoc does have a printer, it is currently being used as seat, when you're sitting at sutekh's keyboard and monitor. So the following is about printing in the Faculty of IT.
Use the lpr command to print files:
lpr -Pprinterid filename
The UTS:IT printers are called blue-draft, blue-clean, red-draft, red-clean and interface. If you send a job to blue it will come out of one of the three printers on level 3 of building 10 (i.e., the ``blue'' level). Ditto for red on level 2. Draft means that what you print will be shrunk down to A5 size, and printed on both sides of the paper, so effectively, you get four pages on the one sheet of paper. Clean is standard printing, as is interface, but you will need your student card to pick it up (good for assignments).
Printing can also be done in ITD, for 11c per page, and it might be a bit faster when assignments are due.
An example: to print file johnboy to blue-draft, use
lpr -Pblue-draft johnboy
Only print text files. Executable, graphics or other binary (not-text) files are not only unreadable by humans but incredibly big, which wastes paper, printing time and ruins the printer. Anyone printing binary files will have their account locked. Sometimes, when you produce a typescript there will be unprintable characters in it. All the printer will produce is ``binary file, unprintable'', or something similar. You should use col -b to remove them --- your lecturer should have told you all about this by now. The other way is to use Vi or ex and use regular expressions to find and delete control characters5.1.
If you've accidently sent a bad file to the printer, squirm in terror --- or use the lprm command to delete it from the queue (see below).
If other people are printing, you have to wait your turn. lpr actually puts your file in a print queue --- don't expect instant printing, especially when assignments are due. The lpq command displays the queue:
lpq -Pprinterid
There is a separate queue for each printer. Your output will look somewhat like
lp is ready and printing Rank Owner Job Files Total Size active leroy 563 glob.tex 6627 bytes 1st hcossell 580 playtime.article_on_boats 12452 bytes 2nd hcossell 631 playtime.ASCII_picture_for_article 97356 bytes
To remove your file from the queue, you'll need to know the job number --- in this case, hcossell has two jobs: numbers 580 and 631. Job 580 was submitted before 631, as it's closer to the active (printing) job.
To remove a file from the queue, use
lprm -Pprinterid jobnumber
Mr Cossell would kill his first job on printer blue-draft with
lprm -Pblue-draft 580
Using lprm without a job number kills all requests from your userid in the queue. Mr Cossell could replace his earlier command with lprm -Pblue-draft, killing jobs 580 and 631 in one savage purge.
There are two direct ways of speaking with friends at other terminals:5.2write (one way communication) and talk (two-way). There is a third, frighteningly dangerous method called IRC, described elsewhere.
First, the mesg command. This stops people from communicating with you---you don't even see requests. Use mesg n at the prompt to cut off communication5.3; mesg y means you're taking messages again5.4. E-mail is received regardless of mesg status. (Email is explained in its own section.)
To use write, type write username at the command prompt. The receiver---the username you specify---will see
message from yourname@yourmachinein their login window and their terminal will beep. If the receiver's login window is obscured---closed or covered by other windows---they may miss your message. If the connection is refused, the receiver is mesg n. Send E-mail instead.
If you did connect, type away. Each time you hit RETURN, the text you've typed will appear in their window. Use CTRLC to finish. The receiver will see EOF (``End of File'').
If they want to reply, they have to write back to you (write~yourname) or use talk.
To use talk, you'll need to know which machine the receiver is using (the name that appears in their prompt: sally, charlie, etc). Most users will be found on charlie. You could use UNIX commands like finger or rusers to find the server, but it's usually faster to pick one randomly.
This time, enter talk username@machine at the prompt. (This means ``talk username at machine.'')
If the receiver is mesg n the window closes abruptly. Again, you'll have to use E-mail until they return to communication.
Otherwise, your screen splits vertically in two and you'll see the message
[Waiting for your party to respond].
The receiver will see:
Message from Talk_Daemon@charlie at 16:14 ... talk connection requested by leroy@charlie. talk respond with: talk leroy@charlie
In your case, leroy@charlie is be replaced by yourname@yourhost. If the receiver wants to talk, s/he enters talk~yourname@yourhost. Their screen also splits vertically and you'll both be told [Connection established]. Whatever you type from now until termination will be seen by the receiver and vice versa. CTRLD ends conversation. If something happens to your screen, such as other students, use CTRLL to redraw the screen.
This response
[Checking For Invitation On Caller's Machine]means talk isn't working---for the moment at least. Use E-mail.
You have now had a short look at some UNIX commands you need to survive in the wilderness of the file system. To extend the metaphor, we have given you a nice big bag of tricks and the only instruction you have received is how to use the penknife5.5. You haven't been told about the jetpack or the 200 room hotel with motor court, but they're down there somewhere in the bottom of the bag and you will have to find them yourself (with the occasional help of a grizzled veteran).
For almost all commands on the system there is some online information telling you all about them. To access this information you use the man command like so:
man man
This will give us the manual page for the man command. The information is displayed using another command called more5.6, which you can use when you want to browse through long documents. To use more you only need to know three letters: b, f and q. Use f to move forward through the document a page at a time and b to move backwards through the document. When you're finished you press q to quit5.7
If you want to do something but you don't know the command you can try searching by any keywords you can think of. To do this use man -k followed by the keyword. Try this example:
man -k manual
This will tell you about xman which is a graphical interface to man.
You will probably find at first that reading the online manual is not very easy. In the beginning you will find it easier to find someone to answer your question for you rather than reading the manual, but as you learn more it will become more difficult to find someone who can answer your newer, leaner, meaner questions and you will have to read the manual pages for yourself, eventually. Maybe not.
One of the basic design policies behind UNIX commands is that they read from standard input (stdin) and write to standard output (stdout). stdin and stdout, unless otherwise specified, are the keyboard and the terminal screen respectively. The clever thing is that stdin and stdout can be specified as other things, such as files, or even output of other commands. Huh? What I just said was that the output from command1 can be used as the input to command2. Even cleverer, the output from command2 could be piped into command3. So? UNIX is built up of simple commands which do one thing, but do it well. Used in combinations they become quite powerful5.8.
To pipe the output of one command into another you place the | symbol between the two commands on the command line. Here is an example of a simple pipe you can use to count the words in a file:
cat vifile | wc
The result of this command will be three numbers: The number of lines, the number of words and the number of characters in the file. What did we just do? cat is used to write a file to stdout. If you executed cat vifile by itself (try it) vifile would be displayed on your screen. Using | we redirected the output from cat's stdout into wc's stdin. All wc does is count the number of lines, words and characters in the file passed to it. In the above example we didn't give wc the name of a file to work on so it knew it had to read from stdin. If we had wanted to we could have simply typed wc vifile.
Now you get to do some work. Here is a pipe:
who | sort | cut -f1 -d\ | uniq | wc | awk '{ print \$1 }'
What did you get? If you typed it in correctly you will get back one number which is the number of users on the computer you are using. How does it work? That's for you to find out5.9.
You can log into one UNIX machine from another. Neat huh? There are lots of reasons why you might want to do this -- perhaps the machine you are currently logged into is being slowed down by thousands of muddling first years compiling Java.
The ssh5.10 command allows you do do this. She is your friend. Treat her well and she'll be good to you.
To invoke her, type something like:
ssh machinename
The machinename will most likely be a short machine name like sutekh. It could also be a fully specified network name like ftoomsh.progsoc.uts.edu.au or an IP address (eg: 138.25.6.3).
After typing in the ssh command it usually asks you for your password. If you get it right you'll be allowed onto the remote machine. Any command you type from then on will be executed on the remote machine. The UNIX prompt normally tells you where you are.
The following example demonstrates logging into charlie from sally (Faculty of IT machines).
sally$ ssh charlie glmarcio@charlie's password: Last login: Mon Mar 3 16:01:24 2003 from sally Sun Microsystems Inc. SunOS 5.8 Generic Patch October 2001 charlie$
After you're finished using the remote machine, type the logout command5.11 and you will be back to your original machine.
charlie$ logout Connection to charlie closed. sally$
If you have a different username, you can log in on the remote machine by using the -l username option to ssh, ie:
ssh -l username machinename
ssh username@machinename also works.
This tutorial may not turn you into a UNIX guru. You may not want to be a UNIX guru. You may feel there are better things to do with your life. You may regret choosing to do Information Technology and in six weeks you may run away to become a cage dancer at the Taxi Club. This may be a Good Thing. This tutorial may create more questions than it answers. This tutorial may not answer any of your questions, but that's okay. You can pass some programming subjects without writing a working program, doing any labs or anything else (thank God!). We did.