The Intermediate Level

The Intermediate Level

Search by subject:

NOTE: At this point it is probably relevant to mention that the information given and commands shown here are those which are most specifically for use under SunOS, since that is the prevailing operating system among the LOCF network. It would be nearly impossible to cover all the variations for the other Unix operating systems (Solaris, OSF, AIX), but you should find that most procedures differ very little and what differences there are can be resolved by consulting the manpage on the local system.

File Manipulation

Now that you know what files are and how to read, write, print, and organize them, you are probably curious as to how you can search, sort, and find them.

A very useful command for one of these tasks is the sort command, which takes the input (generally a file), and sorts each line alphabetically and/or numerically for viewing, but does not change the contents of the file itself. For example, if you had a file called food, which listed your top ten favorite foods in random order, you could perform the following command to quickly see them organized without actually affecting the file, or having to use a word processor:

[151]jess@helios:/u/jess% sort food
english muffins
mashed potatos
You could also simply type the command sort, hit return, and then input whatever text you would like to be sorted, as follows:
[159]jess@helios:/u/jess% sort
[control d]

where you'd hit [control d] on your keyboard when done (nearly all commands work this way).

Before learning any more commands, you should know how to combine them, for the greatest efficiency. This requires only one meta-character, called the pipe command, which looks like this: | on your keyboard. Simply putting it between two commands will enable you to accomplish your goal twice as fast. Essentially, what the pipe command does is take the output of your first command, and feed, or pipe, it to the next. You will find this most handy when used with more or less.

Whenever you expect the output of a command not to fit on your screen, it is wise to pipe it to a text viewer, where you can then see it all by scrolling. If you want to sort a large file, for instance, try this:

[168]jess@helios:/u/jess% sort cccode | more
where "cccode" = filename, and "--More--" is the end of your screen (xterm).

Another common usage of the pipe command is with grep. The command grep searches its input for whatever string you give as an argument. It is similar to the find option in most word processors; the difference being that it returns each of the lines in which the string was found, rather than simply highlighting the specified text. Let's say you have a list of codes, broken out line by line, with their definitions, and you wanted to check the meaning of a particular code without scrolling through the entire file - called codes. Easy:

[178]jess@helios:/u/jess% grep P01500 codes
P01500  Wages-No Workers Comp Insurance
Just type grep, then the string of text you are looking for, and the name of the file you wish to search.

But if your needs get slightly more complicated, and you want to search, not a file, but the output of a command, just utilize the pipe command. Want to see a list of files in your directory that contain a particular word (or string)? Here's how:

[180]jess@helios:/u/jess% ls | grep print
This takes a listing of files in your current directory, which the ls command gave you, and searches it for the string of your choice (in this case: print). Think of grep as a filter, which sifts out any lines not containing the text you specify.

To find out how many lines, words, and characters are in a file (in that order), use the wc (Word Count) command. Type wc and then the file name, or whatever input you would like counted - to wc the file ncd:

[153]jess@helios:/u/jess% wc ncd
      24     113     857 ncd
or to see how many files are in your directory, you could type:
[154]jess@helios:/u/jess% ls | wc
       63	63	557             
The above output means there are 63 files in the current directory, and the total number of characters in all their names is 557.

Or you can combine all of the above mentioned commands, as follows:

[209]jess@helios:/u/jess% grep MH forgs | wc
      73     151    1152
This filtered (greped) the file forgs for the string "MH", and sent the output to wc. The result is a report on how many lines in forgs contain the "MH" string, and how many words and characters are in those lines.

There are many other commands that let you control what you see in a file, or how, such as the head, and tail commands. These commands cut off the first ten lines of a file, and display them on your terminal. If you cared only to see the beginning of a file named hosts, you could do this:

[307]jess@helios:/u/jess% head hosts
opal.UCSC.EDU ( at 2:60:8c:2f:46:84
alphalfa.UCSC.EDU ( at 8:0:2b:3e:39:d9
ad0ncd.UCSC.EDU ( at 0:0:a7:14:79:b
corona.UCSC.EDU ( at 8:0:20:a:2f:f4
sewncd.UCSC.EDU ( at 0:0:a7:0:37:e0
sundown.UCSC.EDU ( at 8:0:20:d:a1:c2
grian.UCSC.EDU ( at 8:0:20:c:81:fe
sundog.UCSC.EDU ( at 8:0:20:7:d1:5e
savitri.UCSC.EDU ( at 8:0:20:c:7d:6
doulos.UCSC.EDU ( at 8:0:20:a:34:fe
You can specify the number of lines, simply by using the -n flag, where n = the number of lines you would like shown. tail, as you might guess, does just the opposite of head; displays the last n lines of a file. Again, the default is 10, but you can change that very easily:
[315]jess@helios:/u/jess% tail -5 hosts
lo8ncd.UCSC.EDU ( at 0:0:a7:0:a7:4d
kaminari.UCSC.EDU ( at 8:0:20:1b:42:8e
mothra.UCSC.EDU ( at 8:0:20:0:5b:34
photon.UCSC.EDU ( at 8:0:20:f:c4:22
inti.UCSC.EDU ( at 8:0:20:a:32:77


You may have noticed that the terms input and output come up frequently when discussing Unix commands. These are also referred to as standard in, and standard out, and indicate what goes in to a command or file, and what comes out. In the following sequence, for example:
[328]jess@helios:/u/jess% more kerr
Jack#   Room#   Occupant
50      8       Computer
51      8       Computer
45      8       Computer
56      9       Koryansky
58      11      Nolthenius
60      12      Peterson
44      12      Temi
41      14      Rank
42      14      Rank
62      15      Visitor
64      17      Robinson
66      19      Miller
68      21      Visitor
01      25      Jessica
03      25A     Asocks
04      25A     Asocks
08      25B     Tabasz
07      25B     Tabasz
103     59      Mail
105     61      Publications
104     61      Publications
the standard in would be the file kerr, and the standard out what was made viewable by more. There is also another in this group, called standard error, which is not discussed here.

The default of standard out is to display on your terminal, or xterm, while standard in's default would be what you type on your xterm. Using the redirect commands, however, will let you control where the standard in comes from, and standard out goes (often abbreviated as stdin/stdout). These commands are represented by the < and > (aka less than, and greater than) characters, where the narrow end is standard in, and the open end, standard out.

The simplest use of these commands is to send the output of a command to a file, rather than your terminal. For example, if you wished to sort a file and save it in a separate file, you need merely to do this:

[195]jess@sol:/u/jess% sort file > file.sort
and you have acheived your goal. In other words, the output of sort file was redirected to the newly created file file.sort. Now, what if you want to save the output in the same file you sorted (meaning, replace the original file with the sorted output)? If you try to accomplish this in the same way, you will encounter an obstacle (at least on the Lick network; not necessarily elsewhere):
[194]jess@sol:/u/jess% sort file > file
file: File exists.
Although this message (and the discovery that the file has not been sorted) may seem frustrating, it is for your own good (and protection)! This obstacle exists to prevent you from accidentally overwriting a file with new data. To overrule this warning, there exist the >! and <! commands, which tell the computer you realize that the file exists already, but you know what you're doing, so please ignore the protection barrier!

You may not want to erase the file you are sending output to, however, in which case, you will be glad to know the >> and << commands, which mean append an already existing file, rather than replace the old data. While the > and < commands assume that the file has not yet been created, the append commands assume that it has. Therefore, if you wished to create the file and append it in one command (it can be done!), you would use the >>! and <<! commands. At this point, you may wonder why that would be necessary, but as you approach the advanced level, it will begin to make sense.

To demonstrate the < command, we introduce the mail command, and a very quick way to send email...

[196]jess@sol:/u/jess% mail jess < backup
What this does precisely is send the file backup to the command mail jess (as its standard input), which in turn sends the file to the user specified (in this case, jess), instead of you typing the message. This is very useful when someone says to you, "email me a copy of that file, willya?". With the redirect and mail commands you can do it in one second, whereas without them, you may have gone through a strange cut and paste process, or something equally creative (unless, of course, you use tkmail).

To get more details, or attempt complex mailings with mail, you could try the manpage or see the mail section.


Groups in Unix are those which determine permissions on particular files. For example, there is a group at Lick for each host which is connected to the network, such as sundog, so that each person who has an account on that machine should be a member, and thus have the appropriate access to its files. The groups are established in a file on helios called /etc/group.

Groups are also designated for many of the same categories as are aliases, such as sw, staff, and faculty. People who use particular software programs often belong to special groups, as do people within the same working group, like eng, for Engineering. To find out which groups you belong to, simply type groups at the command prompt, and you will get a listing.

In order to see which group has been assigned permissions on specific files, use the ls -g command, or ls -lg to see what permissions they have been assigned. If you are not familiar with the ls command, you may want to go back to level one and review it. Otherwise, read the output of the following command:

[143]jess@sol:/u/jess/personnel% ls -lg
total 16
drwxr-xr-x  2 jess     lickstaf     8192 Aug  4 15:57 pay.schedule/
drwxr-xr-x  2 jess     lickstaf     8192 Aug  4 16:00 work.schedule/
As you can see, the two files here belong to the group lickstaf. This is always shown by the fourth column from the left when using the ls -lg command. The g argument is for group, and the l argument for long - combined to make a long listing of the files in the current directory, along with the name of the group they belong to. This does not mean that the group specified actually owns the file, however, simply that they are given special permissions on it.

The group's permissions are described in the first section of the ls output, which consists mostly of the letters r, w, and x. There are a total of ten characters used to indicate permissions, three of which belong to the group.

Usage of Magic Characters

If you've been in a Unix environment very long, you've probably heard about magic characters (also called metacharacters) before, or you've at least run into them - perhaps without knowing. The reason they are called magic is because, essentially they work like such; they do something other than just print on your screen, as the rest of the characters do. They have multiple meanings and, although they can get you into trouble if you don't know what they are, they can save you a lot of trouble if you do.

The basic list of magic characters which you should be aware of (if not wary of) are the following (ordered by their likelihood of being encountered):


Keep in mind that there are others, such as the parenthesis and brackets, but the ones above are most common. As mentioned in the beginners level of this manual, your best bet when trying to avoid magic characters is to use only underscores (_) and dots (.) for punctuation - except within documents (in filenames, for example). Those characters are generally safe - although in some cases the dot means current directory.

Each of the magic characters has different meaning, depending on the particular environment, but the * (asterick) key is pretty consistent in its alter-life as a wildcard in Unix. A wildcard is exactly what you'd expect it to be if you've ever played cards; analagous to the joker. It can indicate any character(s) or string of text, as in the following example.

If you want to look for all the files in your home directory whose names begin with some text, then a dot, and some more text, you might do this:

[229]jess@sol:/u/jess% ls *.*
30tn1005.exe            getimage.tar.Z          readme.txt
9508.cccode.bill              saoim.errs
9510.user.bill          license.dat   
cmd.log                 lick.ip.hosts@          test.fvwmrc
dead.letter             mail.record             tmp.html
emergency.mbox          new.fvwmrc
fax_phones.index        old.fvwmrc
We have asked for a listing of files in our current directory by using the ls command, and then, instead of specifying a filename as an argument, we asked for all files that begin with any text (*), then a dot (.), and more text (*).

The dash (-) is usually known for its meaning as a flag, or argument, in a Unix command. With most commands, the - introduces an argument, and thus would surprise you with its results, had you meant for it to indicate the actual printed character: -

The obvious question which comes to mind at this point is what to do if you happen to need a magic character to portray its printed meaning. Obviously, it can't be that we never use those characters in Unix text! Of course not, and that is why we have a special process called quoting, which allows you to escape the special meaning of metacharacters.

Here is how you can put to use two magic characters in one command:

[233]jess@sol:/u/jess% ls -l *.*
-rw-rw-r--  1 jess       403782 May  8  1995 30tn1005.exe
-rw-r--r--  1 jess       121947 Sep 21 09:10 9508.cccode.bill
-rw-r--r--  1 jess         1133 Nov  2 14:28 9510.user.bill
-rw-r--r--  1 jess     19944871 Dec 12  1994 cmd.log
-rw-------  1 jess           52 Oct 10 15:19 dead.letter
-rw-------  1 jess            0 Aug 28 10:35 emergency.mbox
-rw-r--r--  1 jess           20 Apr 12  1995 fax_phones.index
-rw-r--r--  1 jess       216683 Sep 22 16:23 getimage.tar.Z
-rw-r--r--  1 jess      1482752 Mar  6  1995
-rw-------  1 jess         1683 Aug  2 16:20 license.dat
lrwxrwxrwx  1 jess           42 Sep  7 23:33 lick.ip.hosts -> /net/lick/usr/localdir/tools/lick.ip.hosts
-rw-------  1 jess       379483 Nov  7 10:59 mail.record
-rw-r--r--  1 jess        19408 Jun 20 16:10 new.fvwmrc
-rw-r--r--  1 jess        11863 Jun  8 17:09 old.fvwmrc
-rw-r--r--  1 jess        22160 Oct 20  1994 readme.txt
-rw-r--r--  1 jess            0 Jun 20 16:19 saoim.errs
-rw-r--r--  1 jess       705397 Oct 16 14:04
-rw-r--r--  1 jess        15588 Jul 12 13:20 test.fvwmrc
-rw-r--r--  1 jess         5238 Jun 16 13:02 tmp.html
to request a long listing of all the files in your current directory whose names begin with any text, end with any text, and have a dot in between. Should a filename have begun with a dot, and then some text, it would not have qualified because the asterick says that, although it can be any text, there must be some text in its place.

Those files beginning with a dot fall under another category, however, which brings us to the subject of dotfiles.


At this point you are probably curious as to how you can change certain things in your environment, such as your default editor, or printer, and what applications start up when you login. These variables can be determined via dotfiles, which are files generally located in your home directory that begin with a dot (.), and are used to configure various resources. These files do not usually appear in the listing you get when using the ls command, because they are suppressed unless you use the -a argument.

The most useful among these is the .cshrc file (assuming you are running a C shell), which initializes and configures your shell, or home environment.

The .cshrc file is one of the first things your computer reads at the beginning of a session, or at anytime you specify by typing the command, source .cshrc, and tells it where to look for certain things such as commands, by setting environment variables, or envars.

The beginning of a typical .cshrc file looks similar to this:

# Initialization of csh.  Suggestions, questions, and flames to syscrit
# Uncomment the following if you plan to run the KHOROS image and signal
# processing system.
#source $HOME/.khoros_env
# directories that csh searches to find commands.
setenv SYBASE /usr/local/sybase
setenv SWAN_HOME /usr/local/sybase/swan
setenv SWANBIN /usr/local/sybase/swan/bin
setenv SQRDIR /usr/local/sybase/layered/sqr/syb/workbench/bin
setenv FMHOME /usr/local/frame
setenv MACH `/usr/bin/mach`
setenv OPENWINHOME /usr/local/openwin
setenv TKWWW_DIR /usr/local/www/cc/manual
setenv PRINTER helios
set path = (~/bin ~/bin/$MACH /usr/ucb \
     /usr/local/bin/X11 $OPENWINHOME/bin $OPENWINHOME/bin/xview \
     /usr/local/info/sw/bin/ /usr/local/frame/bin /usr/local/tcl/bin \
     /usr/local/sybase/bin $SWANBIN $SQRDIR \
     /usr/lang /bin /usr/bin /etc /usr/etc /usr/5bin \
     /usr/bin/X11 /usr/sbin /usr/lib /usr/local/lib /usr/local/5lib \
and should only be writable, or editable, by its owner, or the person whose home directory it's located in. The syntax of most lines in this file is "setenv", then the name of the variable being set (e.g. PRINTER), and what it is being set to. This is the process by which one would go about changing their default printer, which is associated with the user account, rather than the hardware that is being used.

Since copies of a .cshrc file are available in /usr/local/examples, it is not necessary to create a .cshrc file from scratch, but merely to copy one from that location, and edit it with your personal preferences.

For example, in the .cshrc segment above, it is apparent that the user has specified helios as their default printer. To change this, you need only to change the word helios to the new printername, such as lobo, if you are in the business office, and type the magic command, source .cshrc, for the adjustment to take affect. What the source command does exactly, is tell the computer to reread whatever file is specified. Until this is done, any changes you make to a dotfile will not generally be noticed.

Often, when using a new application for the first time, it will be necessary to make changes to the .cshrc file in order to start the program. Usually, these changes will be explained by either your System Administrator, or the accompanying manual to your software.

The .cshrc file is also responsible for another important process, and that is setting your path. The path establishes where (in which directories) commands are looked for, and often can leave a command undetected if not specified within it. Whenever you get the message

command: Command not found.
and you expected this command to work, there is a good chance that it exists, but cannot be found due to its location not being observed by your path. This can be resolved by the use of the which command. If you know of another user for whom the particular command works, simply ask them to do the following:
[238]jess@sol:/u/jess% which commandname

Typing which and the command you are searching for will produce the location where it was found by this user. Then, you can check your .cshrc file to see if that directory is included in your path:

set path = (~/bin ~/bin/$MACH /usr/ucb \
     /usr/local/bin/X11 $OPENWINHOME/bin $OPENWINHOME/bin/xview \
     /usr/local/info/sw/bin/ /usr/local/frame/bin /usr/local/tcl/bin \
     /usr/local/sybase/bin $SWANBIN $SQRDIR \
     /usr/lang /bin /usr/bin /etc /usr/etc /usr/5bin \
     /usr/bin/X11 /usr/sbin /usr/lib /usr/local/lib /usr/local/5lib \
     /usr/hosts /usr/local/elm/bin /usr/local/new/pbm . )
Here you can see that /usr/local/bin is nowhere to be found in this path, and adding it would solve the problem. Don't forget to source .cshrc before attempting the command again!!

There is another way to quickly change environment variables from an xterm, without having to edit any dotfiles. In the case of the PRINTER variable, one can type

[234]jess@sol:/u/jess% setenv PRINTER floor0
to change it to floor0 for the remainder of the session. Keep in mind that this will only affect what is printed directly from the xterm where you typed the command, or from any application that is started from that xterm after you did so. That is, if you already have tkmail open, and you type the above command, and ask tkmail to print a message, it will still go to the previously specified printer. Once you shut down and restart tkmail from said xterm, however, printouts will go to floor0.

When adjusting the variables repeatedly, it is easy to forget what you currently have one set to. To check this, just type

printenv VARIABLE 
where VARIABLE is that which you wish to check, and the output will be your answer.

Other useful dotfiles are those that configure your window manager, .fvwmrc if you are using fvwm, and .aliases, which assigns abbreviated aliases to various commands, so that they are more easily accessed.

These files are handy in many ways, and are guided throughout by commented lines which explain what is being done in each area. Commented lines are those that have a # sign at the beginning, which tells the computer to ignore all that follows until a new line begins. The advantage to this is for writing comments that are only meant to be read by humans.

The .fvwmrc file (or .twmrc, or .olwmrc, depending on the window manager you use) can set anything from fonts, to colors, to geographical placement of windows and icons on your screen. One common use for it is to assign utilities to a popup menu which is started up with the window manager. Most users have certain applications which they use frequently, and to save typing, or memorization of commands, they can be added to the .fvwmrc file once and never worried about again, since they will become convenient little items on a menu.

The .aliases file can be edited with whatever you like to make life easier. In most .aliases files here at Lick, the logout command is aliased to lo, so that a user can logout by typing lo, which the computer interprets as meaning logout. For instance, if you so choose, you can set the key string, hi to xterm -e elm &, causing elm to be started up in its own xterm whenever you type hi.

Just as with the .cshrc variables, you can set aliases without actually editing the .aliases file. This is done similarly as below:

[240]jess@sol:/u/jess% alias hi who
Again, this will only work for the remainder of the session, and from applications launched from the xterm in which you typed it.

You must be cautious when editing the .aliases file, however, for a couple of reasons. For one, what you add can conflict with commands already set elsewhere in the system, so that when you mean to get one response, you will get the other. This can cause many problems, so it is important to check for the existence of commands before aliasing them.

Also, if you set an alias to something dynamic, such as rm *, you are greatly increasing the chances of accidentally doing something harmful.

Used carefully, though, you should find dotfiles to give you a lot more control than you may have previously thought you had over your Unix environment.

Once you begin using these and other files, and realize how powerful they are, you might become concerned about access to them. Read on to discover the key command for controling such.

File Permissions


You may be wondering how the directories and files you create get their permissions set. You can set the permissions of a directory or file with the umask (user mask) command. The umask command can be set as a default in your .cshrc file and therefore create the permissions automatically for you.

The format of umask is

umask [nnn]

where nnn is an octal code obtained by summing access codes for each access group. The read access code is 4, the write access code is 2 and the execute or search code is 1. You specify a file's mode with three numbers: the user's access code, the group's access code and the other's access code. Therefore a permission code of 6 allows read and write access (rw-). A permission code of 5 allows read and execute access (r-x).

By default, files use mode 666 and directories use mode 777 (allows you to search the directory). Mode 666 (rw-rw-rw-) allows everyone to read and write that file. Mode 777 (rwxrwxrwx) allows everyone to read, write and search the directory.

To change the setting, you use umask to disble the unwanted access. Suppose we want to create a file called astro and you do not want others to write in it, you can use the umask command to disable the access codes you do not want. The command

umask 002

will do the job. The three digits aply to the owner, group and others, repectively. You did not change the owner and group becuase you had a (0), but the write permission (2) was removed, therefore when you create the file, others will not be able to write in your file. The mode for directories is 775 and the mode for files 664.

If you type just the command umask it will tell you what your default settings are:

[68]cc@sol:/u/cc% umask

Here are more examples. Suppose you want to turn off all access permissions for others and and allow read and search access only to users in your group. The umask argument

umask 027

will create directories with mode 750 and files with mode 640.

If you really want to restrict access to everyone the umask argument

umask 777

will produce a truly secure system. This will not even allow you to access your files. So be very careful.

Remember that all umask arguments apply to the default of 777 for directories and 666 for files.


In order to change permissions on specific files, once they have already been created, you should use the chmod command. First, take a look at the current permissions:
[194] jess@sol:/u/jess/personnel/pay.schedule% ls -l
total 19
-rw-r--r--  1 jess           75 Apr 16 11:02
-rw-r--r--  1 jess         2904 Aug  4  1995
-rw-r--r--  1 jess          933 Apr 16 11:02
[195] jess@sol:/u/jess/personnel/pay.schedule% 
Then, you have two options for changing them. The easiest, but least dynamic way of doing so is via the character symbols; r - read, w - write, x - search and execute. With this method, you list the users for whom you would like to change permissions, which permissions you would like to change (and how), and for which files you are applying this.

The applicable users are specified by u - for owner (user), g - for group, o - for others (all users not belonging in the preceding two categories), a - for all (all users). For example, the permissions on the above files are such that only the owner (jess) can write them, but anyone can read them. To allow all users execute permission, do the following:

[198] jess@sol:/u/jess/personnel/pay.schedule% chmod a+x *
Now, you have given all users execute permission on all files in the current directory:
[199] jess@sol:/u/jess/personnel/pay.schedule% ls -l
total 5
-rwxr-xr-x  1 jess           75 Apr 16 11:02*
-rwxr-xr-x  1 jess         2904 Aug  4  1995*
-rwxr-xr-x  1 jess          933 Apr 16 11:02*
[200] jess@sol:/u/jess/personnel/pay.schedule% 
Notice that the files now have a trailing asterisk. This is because, in giving users execute permission, we have now made these files executables. The * is used to indicate this here, because at Lick the ls command has been aliased to ls -F, which instructs ls to include file-type indicators in its output. See the manpage for details.

To remove permissions, simply substitute the + with -:

[210] jess@sol:/u/jess/personnel/pay.schedule% chmod o-r
[211] jess@sol:/u/jess/personnel/pay.schedule%
The read permission has been removed for other (o) users on the file:
[257] jess@sol:/u/jess/personnel/pay.schedule% ls -l
-rwxr-x--x  1 jess         2904 Aug  4  1995*
[258] jess@sol:/u/jess/personnel/pay.schedule% 

With this straightforward approach, you cannot remove and add permissions in the same stroke, nor can you add a particular permission for one group of users, while adding a different type for another. But by using the octal code sytem, as described in the umask section above, one can accomplish these tasks quite efficiently.

Giving the owner of each file in the current directory read, write, and execute permission, and removing these permissions for all other users, would take several steps through the first technique, but can be done with a one command procedure otherwise:

[224] jess@sol:/u/jess/personnel/pay.schedule% chmod 700 *
A quick ls command demonstrates the success of this effort:
[225] jess@sol:/u/jess/personnel/pay.schedule% ls -l
total 5
-rwx------  1 jess           75 Apr 16 11:02*
-rwx------  1 jess         2904 Aug  4  1995*
-rwx------  1 jess          933 Apr 16 11:02*
[226] jess@sol:/u/jess/personnel/pay.schedule% 


The group ownership can be changed on a file, by the owner only, by using the chgrp command (change group). It is used in the following manner, that is, typing chgrp, the group you wish to change to, and the filename on which you wish to change it:
[144]jess@sol:/u/jess/personnel% chgrp sw pay.schedule
Now the group permissions shown below on pay.schedule will apply to the sw group:
[145]jess@sol:/u/jess/personnel% ls -lg
total 16
drwxr-xr-x  2 jess     sw           8192 Aug  4 15:57 pay.schedule/
drwxr-xr-x  2 jess     lickstaf     8192 Aug  4 16:00 work.schedule/
The second set of three permissions, in the first column on the left, which now hold r-x, are those of group sw. The first three are of the owner, jess, and the last three of all other users. Remember that the first character (here shown as a d, for directory) is not a file permission, but rather describes what type of file it is.

Remote Login

Here at Lick Observatory we have several machines that one can use if they have permission. Our public machines are helios (anyone with an account at Lick can use this machine), ra, sol, and bigdog. We also have many private machines and if you have an account at those machines, then the remote login will be handy.

Lets say you first logged into helios and you now need to use your private-host, you can do a remote login to your private-host without logging out of your current session and having to login to the other host. Here are the basic commands and their function (the information contained in brackets are optional arguments):

rsh remotehost [ -l user ] command

will login to the remotehost and execute the command, directing the standard output of the remote command to its standard output.

rsh remotehost [ -l user ]

will just log you in to the remotehost

rlogin remotehost [ -l user ]

will just log you in to the remotehost

rcmd remotehost [ -l user ] command

runs the given command on the specified remotehost in the background; standard out and standard error are redirected to /dev/null (nowhere). This is mainly, and possibly only, useful for running Xwindows or OpenWindows applications remotely.

rcmd remotehost [ -l user ]

will just log you in to the remotehost

When logging in remotely, you are often prompted for the name of your display, and one or more default choices are usually given. If you want to start up any new windows from a remote login session, you will need to ensure the display environment variable is set correctly. This tells the machine which display you are using, and will enable it to use it as well.

This can be done as simply as:

[125]jess@helios:/u/jess% setenv DISPLAY displayname
where displayname is the name of your terminal or workstation with a :0 trailing it. For example, if you are working on bigdog, your displayname would be bigdog:0. If you are uncertain what this should be, you can check it in a standard (non-remote) session by typing:
[124]jess@helios:/u/jess% printenv DISPLAY
The output would be your displayname with an additional .0 after it. You do not need to enter the .0 portion of the name when setting this.

In order to display remote applications, one more command is necessary. Since we use access control at Lick, unless the remote machine is helios, it will not inherently have permission to display on your local screen. To grant it such, use the xhost command in an xterm on the machines you first logged into:

[200] jess@sol:/u/jess% xhost bigdog
bigdog being added to access control list
[201] jess@sol:/u/jess% 
where bigdog is the remote machine you wish to grant access. Always be sure to revoke the access when finished by typing:
[201] jess@sol:/u/jess% xhost -bigdog
bigdog being removed from access control list
[202] jess@sol:/u/jess%

Remember, xhost must be typed on the original machine you logged in with. If you logged in to sol, then remotely logged into bigdog, and want to launch another bigdog window, you must grant access from a sol window. The xterm from which you remotely logged into bigdog is no longer a sol window, until you logout.

Complex Printing

Postscript Files

All UCO/Lick printers are PostScript printers. You may send either a text file or a Postscript file directly to the printer. Text files are automatically converted to Postscript. You may not send a DVI file to the printer without first converting it to PostScript. Use dvips or lpr -d filename on Digital UNIX when printing a DVI file.

There are a number commands designed specifically for postscript printing, such as psnup and pslpr. See the manual page on Transcript for a complete listing.

Large Files

When you print a file, a temporary copy of the file is made in the /var/spool directory. It remains there until the print job has completed. If the file is large, i.e. bigger than 1 Megabyte, there is a risk that it will fill up the root file system, preventing your job, and any others from printing. Use the lpr -s option to prevent this. This makes a symbolic link instead of a copy in the spool directory. To see how much space there is in the spool directory type df -k /var/spool/printers.

Using the following list of each printer, as of 4/16/96, and what machine it is hosted by, you can be sure that you are on the correct machine before printing a file at UCO/Lick:

	PrinterName	HostName

ad0ncd helios ad9ncd helios adbncd shoppe ame ame apple02 ra color ra corona corona dbmncd helios eppsprt helios giant giant hp00 bigdog hp01 hires hp02 helios hpplotter photon lh4ncd corona lobo helios orcupine corona phaeton phaeton room164 bigdog room419 savitri shoppe shoppe smfhpnp sundown sundog sundog sundown sundown super super surface surface surya surya tek01 helios ucscloa ucscloa ucscloc ucscloc

You may use the command lpstat -s to see what the default printer is and what other printers are available. Some printers are only accessible by a limited group of users.

If you are familiar with the /etc/printcap format, you can always check that file for the current printers, and their spooling hosts.

Please remember, however, that it is considered impolite to print a file larger than 3 Megabytes during working hours on public printers if anyone else is waiting. If attention is drawn to such an incident the syscritters may remove the printer job from the queue. A megabyte is one million bytes, so this is not your average file, but you can always check the size by using the lpq command.

Changing Target Printer

UNIX lpr chooses the printer your job will be sent to in this order:

1) The printer specified on the command line (when given)
2) The value of the environment variable PRINTER
3) The UNIX hosts default printer

Each UNIX host has a default printer assigned to it by the Management. This is typically the printer that is in closest proximity, it may be a private printer. If you would like to send a file to a printer other than the default, or what has been specified in the PRINTER envar, use the -P option of lpr (this is also available for many other types of printing commands):

[290] jess@sol:/u/jess% lpr -Pad0ncd filename
[291] jess@sol:/u/jess% 
where ad0ncd is the name of the desired printer.

Color Printing



Each command you execute, or application you run, becomes a process in Unix. Often, you will need to examine these processes for various reasons. They may not have stopped correctly (or at all), or they may be using excessive memory. For a simple list of which processes, or jobs, you are running, use the command jobs. With the -l argument, you get the process id as well as the short name and brief status of each process:

[369]jess@sol:/u/jess% jobs -l
[1]  + 21908 Running                forms jess
[2]  - 21909 Running                netscape
[3]    21910 Running                wisql
[4]    22248 Running                fvwm
The jobs command, however, will only show you those jobs which you started from the xterm it is typed on. If you want much more detail, or a complete list of processes, the ps command will do the trick. This command is slightly more complex in that it has several arguments, and the information it displays is not so self-explanatory.

First of all, the ps command, when given no arguments, displays information on essentially the same processes which the jobs command would examine. As shown here:

[374]jess@sol:/u/jess% ps
21881 p6 S     0:10 -tcsh (tcsh-6.04)
21908 p6 IW    0:36 /usr/local/tcl/bin/wishx -f /usr/local/tcl/bin/forms jess
21909 p6 S     0:36 netscape
21910 p6 IW    0:34 /usr/local/tcl/bin/wishx -f /usr/local/tcl/bin/wisql
22248 p6 S     0:44 fvwm -s
22341 p6 IW    0:00 /usr/lib/X11/fvwm/GoodStuff 8 5 /u/jess/.fvwmrc 0 8
24453 p6 S     0:00 /usr/lib/X11/fvwm/FvwmPager 10 5 /u/jess/.fvwmrc 0 8 0 0
24534 p6 R     0:00 ps
21882 p7 IW    0:51 /usr/local/bin/elm
Here the complete path which was used to begin the process is given, along with the time it began, its current status (under the STAT column), and its process id (PID). It also includes processes which you probably didn't know existed, as they were executed automatically at the beginning of your session. One example would be the -tcsh process, pid 21881, which is the shell, or xterm, from which you are operating.

The TT column indicates which terminal the process was started from. In the above example, most of the processes were started on the p6 terminal, except for the last one, /usr/local/bin/elm.

For more control with the ps command, some helpful arguments are a, u, x, and ww. Remember, the examples given here are those appropriate for the SunOS operating system, and may not work properly under a different environment. Always refer to the man page for a comprehensive list of command arguments and their usage.

The -a argument instructs ps to display all the current processes on the particular machine from which it is executed, not just your own. The -u argument adds more useful fields to the output, such as the USER column, which shows the owner of each process. The -x argument causes all types of processes to be shown, not just those with a controlling terminal.

Adding the ww argument will get the full, wide, output. Rather than cutting off process names to fit on the screen, they will wrap around it. When all the above described arguments are used together, as follows, they will bring some extensive information:

[382]jess@sol:/u/jess% ps auxww | more
jess     24783 30.8  1.0  320  580 p6 R    12:44   0:00 ps auxww
root         1  0.0  0.0   52    0 ?  IW   Nov 27  0:41 /sbin/init -
root       124  0.0  0.0   76    0 ?  IW   Nov 27  0:07 rpc.mountd -n
root         2  0.0  0.0    0    0 ?  D    Nov 27 41:25 pagedaemon
root        65  0.0  0.2   68  136 ?  S    Nov 27  2:51 portmap
root         0  0.0  0.0    0    0 ?  D    Nov 27 96:23 swapper
tucker   23509  0.0  0.2  180   96 ?  S N  Mar  4  1:45 xbiff -name meter1
wizard   23860  0.0  0.0   76    0 co IW   Dec  1  0:00 -csh (csh)
root        74  0.0  0.0   40    0 ?  IW   Nov 27  0:10 keyserv
root        93  0.0  0.0   16    0 ?  S    Nov 27  7:54  (biod)
root        87  0.0  0.2   44   92 ?  S    Nov 27 23:16 in.routed
sys         71  0.0  0.0   36    0 ?  IW   Nov 27  0:00 ypbind
root        95  0.0  0.0   16    0 ?  S    Nov 27  7:55  (biod)
root        94  0.0  0.0   16    0 ?  I    Nov 27  7:57  (biod)
root       116  0.0  0.0  172    0 ?  IW   Nov 27  0:29 sendmail: accepting connections
root       137  0.0  0.0   76    0 ?  IW   Nov 27  0:00 rpc.lockd
root       107  0.0  0.0   60    0 ?  IW   Nov 27  1:51 syslogd
root       123  0.0  0.0   28    0 ?  S    Nov 27  0:01  (nfsd)
Here I piped the output to more, so it wouldn't run off the screen, but the best solution is to grep out the data you are interested in. Say you want to look at a particular user's processes - just grep their username out:
[390]jess@sol:/u/jess% ps auxww | grep jess
jess     21881  0.0  0.6  292  368 p6 S    08:01   0:11 -tcsh (tcsh-6.04)
jess     22248  0.0  0.6  144  320 p6 S    08:29   0:51 fvwm -s
jess     22341  0.0  0.0   76    0 p6 IW   08:39   0:00 /usr/lib/X11/fvwm/GoodStuff 8 5 /u/jess/.fvwmrc 0 8
jess     21864  0.0  0.2  184  136 ?  S N  08:01   0:02 xclock -name meter0
jess     21909  0.0  0.9 1456  516 p6 S    08:02   0:38 netscape
jess     24906  0.0  0.3   32  200 p6 S    12:50   0:00 grep jess
jess     24453  0.0  0.3   56  144 p6 S    12:06   0:01 /usr/lib/X11/fvwm/FvwmPager 10 5 /u/jess/.fvwmrc 0 8 0 0
jess     21910  0.0  0.0 1236    0 p6 IW   08:02   0:34 /usr/local/tcl/bin/wishx -f /usr/local/tcl/bin/wisql
jess     24905  0.0  1.0  324  580 p6 R    12:50   0:00 ps auxww
jess     21882  0.0  0.0 1244    0 p7 IW   08:01   1:00 /usr/local/bin/elm
jess     21908  0.0  0.0 2836    0 p6 IW   08:02   0:36 /usr/local/tcl/bin/wishx -f /usr/local/tcl/bin/forms jess
If you grep your own username out, you will end up with the same output as if you hadn't typed the -a argument. Notice also that in this version of ps it is not necessary to use the - preceding dash. That may not always be true, so check the manpage!

The first couple columns in the above output are probably clear enough. They are the owner of the process, and the process id. Other columns of interest are the last column, which shows the process name, and the preceding two columns which show the time they began, and how long they've been running.

Also, the fifth column from the left, in this output from the ps auxww command, shows the size of the process in kilobytes, and the fourth column from the right shows its status. The manpage gives a detailed translation of the status field. These columns are particularly useful when you are looking for candidates to kill in order to free up space.

When doing so, keep in mind you can only kill your own processes, but you may always search for the offending ones and notify the owner of such. To kill a process, simply use the kill command, and the process id: kill sends a signal to the process and tells it to go away in one of several ways, depending on the level which it is given.

Generally, it is best to try kill by itself, which has a default "soft" kill, and gives the process a chance to terminate properly. Often, however, the process is beyond reach in this way, and must be a given a hard kill, usually with the -9 flag:

[409]jess@sol:/var/adm% kill -9 25095
There will be no output, so you may want to check ps again to be sure the process is gone.

Man Pages

Man pages are helpful excerpts of online manuals in Unix, which are good for referencing commands, and especially their various arguments. To access a man page on the command you are interested in, just type man and the command. You can even look up the manpage on manpages!:

jess@sol:/u/jess% man man
Reformatting page.  Wait...
The output above is normal, and should be followed by the description of the command flashing on your xterminal through the editor, more. A typical manpage begins with an explanation of the name of the command, its proper usage (synopsis), and a description. It then proceeds with the options, or arguments, of the command, and sometimes continues on with some brief troubleshooting.

Manpages are very limited in their scope, in that they assume one has a general knowledge of Unix, and of related commands. They are not meant to be a tutorial, but make an excellent reference, since they cover almost all Unix commands. Another downside is that if you do not know the name of the command you are doing, but simply what you want to do, you will probably have a hard time finding the correct manpage.

One solution to this is the command apropos, or man -k, which displays commands whose name in manpages contains the keyword (string) you specify, in other words, only the appropriate command. For example,

[205]jess@nazca: /u/jess: man -k date
ascftime	strftime (3c)	- convert date and time	to string
asctime		ctime (3c)	- convert date and time	to string
asctime_r	ctime (3c)	- convert date and time	to string
cftime		strftime (3c)	- convert date and time	to string
ckdate		ckdate (1)	- prompts for and validates a date
ckgid		ckgid (1)	- prompts for and validates a group id
ckkeywd		ckkeywd	(1)	- prompts for and validates a keyword
ckrange		ckrange	(1)	- prompts for and validates an integer
ckuid		ckuid (1)	- prompts for and validates a user ID
ckyorn		ckyorn (1)	- prompts for and validates yes/no
ctime		ctime (3c)	- convert date and time	to string
ctime_r		ctime (3c)	- convert date and time	to string
date		date (1)	- write	the date and time

Media & Peripherals

Here at Lick, we offer various types of peripherals and media via public machines. At this date (6/20/96), we have the following available:

The LOCF user rooms, currently consisting of Kerr Hall room 8, room 62, and room 460, contain most of the publicly accessible workstations and equipment. Since no listing of their exact location could ever stay current for very long, it is not attempted here. One should either ask other users, simply search the various user rooms themselves, or check the messages facility.


Media for all of the above drives is available from the computing facility in room 25, where one can purchase such by providing the name of the grant to be charged. This resource is available for your convenience, but for any large quantities of media, it is recommended you buy individually through the purchasing department.


All of the public Exabyte Tape Drives require the use of a locally written program, called request/release. These commands are designed to control access to the tape drives in common use. Before attempting to access a public Exabyte tape drive (currently those on helios, ra, and bigdog), it is necessary to request it. To find out which devices are available, and their status, type request:

[209]jess@bigdog:/u/jess% request
collecting device info...

        /dev/rmt0[a,h,l,m] is **AVAILABLE** 
        /dev/rmt1 reserved by xu on Thu Jun 20  9:00:40 1996
        /dev/rmt2[a,h,l,m] is **AVAILABLE** 

density codes: a=DEFAULT(low) h=high l=low m=N/A(medium)
Now, to access one of the available drives, type request followed by the device name:
[211]jess@bigdog:/u/jess% request rmt0
collecting device info...

        /dev/rmt0[a,h,l,m] is **AVAILABLE** 
        /dev/rmt1 reserved by xu on Thu Jun 20  9:00:40 1996
        /dev/rmt2[a,h,l,m] is **AVAILABLE** 

density codes: a=DEFAULT(low) h=high l=low m=N/A(medium)
        DEV_ASSIGN: device /dev/rmt0 assigned to jess

When you are finished with the drive, please always remember to release it!
[220]jess@bigdog:/u/jess% release rmt0
collecting device info...

        /dev/rmt0 reserved by jess on Thu Jun 20 10:51:11 1996
        /dev/rmt1 reserved by xu on Thu Jun 20  9:00:40 1996
        /dev/rmt2[a,h,l,m] is **AVAILABLE** 

density codes: a=DEFAULT(low) h=high l=low m=N/A(medium)
        DEV_FREE: device /dev/rmt0 released by jess

jobs = jess.835321871.a Thu Jun 20 18:51:11 1996

If someone forgets to release a tape drive, it will be blocked and available to no one.


Several 4x CDROM Drives are provided by the Lick Computing Facility for general use. On Sun machines running Solaris, the operating system automatically takes care of mounting the CDROM drive. On Sun machines running SunOS, one would normally need to handle this manually. However, a program called cdmount is available by which you may easily prepare the CDROM drive for your use.

Typing cdmount with the -m argument will mount and export the CDROM on /cdrom, seen as /cdrom/hostname by remote hosts. That is, when attempted on machines which actually have a CDROM drive attached.

When finished using the cdrom drive, always unmount it with the -u argument. Type cdmount -help for specific instructions.

CDROM Drives on alpha machines usually have a device address of either /dev/rz4c, or /dev/rz12c. They can be mounted with the mount (/usr/sbin/mount), and umount (/usr/sbin/umount) commands.

CD-R: RECORDABLE CDROM DRIVE ***Under Construction**


The devinfo command, on Sun systems only, will query the scsi bus and report all known attached devices. The format may at first appear cryptic, but should provide the information you need. Here is an example:

[233] jess@sol:/u/jess% devinfo
Node 'SUNW,SPARCstation-5', unit #0 (no driver)
        Node 'packages', unit #0 (no driver)
        Node 'options', unit #0 (no driver)
        Node 'aliases', unit #0 (no driver)
        Node 'openprom', unit #0 (no driver)
        Node 'iommu', unit #0
                Node 'sbus', unit #0
                        Node 'espdma', unit #0
                                Node 'esp', unit #0
                                        Node 'sd', unit #1
                                        Node 'sd', unit #0
                        Node 'audio', unit #0
                        Node 'SUNW,bpp', unit #0
                        Node 'ledma', unit #0
                                Node 'le', unit #0
                        Node 'SUNW,CS4231', unit #0 (no driver)
                        Node 'power-management', unit #0 (no driver)
        Node 'obio', unit #0
                Node 'zs', unit #0
                Node 'zs', unit #1
                Node 'eeprom', unit #0 (no driver)
                Node 'slavioconfig', unit #0 (no driver)
                Node 'auxio', unit #0 (no driver)
                Node 'counter', unit #0 (no driver)
                Node 'interrupt', unit #0 (no driver)
                Node 'power', unit #0 (no driver)
                Node 'SUNW,fdtwo', unit #0
        Node 'memory', unit #0 (no driver)
        Node 'virtual-memory', unit #0 (no driver)
        Node 'FMI,MB86904', unit #0 (no driver)
[234] jess@sol:/u/jess% 
It is the information furthest to the right you are interested in, and you can probably ignore all but the sbus section. Now that you have narrowed it down, you will need to know the standards of Unix scsi device addresses, to completely decode these labels.

Because these criteria are very operating_system dependent, they are here divided by such:

To access a drive attached to a Unix machine, one must know where it is located, not just physically, but dynamically. A device address usually begins with /dev/, followed by a string of numbers and letters.


Scsi Disk Drives
On Sun systems (running SunOS), a SCSI Disk drive is generally referred to as /dev/sdxx (sd stands for Scsi Disk) where xx is a number, the SCSI-id, and letter, the partition. Usually, the c partition is one which refers to the entire capacity of the drive, and should be the one referenced in most commands explained here.






There are mainly two types of aliases; those that are configured in your .aliases file, and define aliases for commands, and those that apply to email addresses. Within the email aliases, there are again two types of aliases; those that are defined individually, generally within a particular mail program, and those which are defined globally.

At Lick Observatory, we keep most of the global aliases in a file on helios called /etc/aliases, while some are maintained through a link with the database (Sybase) that indicates which category particular users belong to. One example of these would be the grads alias, which contains the email addresses of all grad students with Lick Observatory.

This allows one to send an email to simply grads if they wish to address all of the graduate students, rather than having to type each of their email addresses. The following is a list of common aliases such as this, which may be of use to you:

Alias:		Description:

acadres		Lick Academic Residents
grads		Lick Graduate Students
emeriti		Lick Emeriti
emeritus	Lick Emeriti
faculty		Lick Faculty
postdocs	Lick PostDocs
visitors	Lick Visitors/Guests
observers	Lick Observers
staff		Lick Staff
cpmc		Lick CPMC Members
sw		Lick Software Group
syscrit		Lick People Who Handle Hardware Problems
lobos		Lick Business Office
everybody	Virtually Everybody @ Lick (acadres, emeriti, grads, faculty,
		postdocs, staff, visitors, joel)	
There is also a complete listing of current Lick aliases. Each user's name is also aliased in /etc/aliases so that, should someone address an email to their first and last name, rather than username, it will be sent to their username anyway. That is, as long as they spell it correctly.


All hosts connected to the Lick network, and user accounts within it, are subject to monthly charges calculated via the billing software. There is a web page containing all possible Computing Facility charges, and their rates, as well as one where you can query the database for your Monthly Billing Statement.

You can also check some information associated with particular users, hosts, and cccodes, in order to resolve possible errors in your bill.

Billing procedures and rates are determined via the CPMC - Computer Planning and Management Committee, which meets monthly.

Proceed to Level 3?

Return to the Index?

Comments/Questions/Suggestions to:

UCO/Lick Observatory
University of California
Santa Cruz, CA 95064
1 831 459 2303