Converting to the Unix T shell at Princeton University
Craig Upright
2.N.1 Green Hall
Department of Sociology
Princeton University
Princeton, New Jersey 08544
(609) 258.2452
This page gives instructions pertaining to
Getting the basic commands
Changing your shell
Changing shell environment settings
Adding aliases
Adding a couple of scripts
plus, some tips that will help you
Watch your quota !!
If you made it here then you must have at least some desire to get to know
your unix account a little bit better. The tips that I give below are
designed to remove some of the frustrations of working with of the
mainframe, and help you manage your account a little better. The main
philosophy here is that we should be spending our time in graduate school
worrying about the content of our papers and the relevance of our
statistical output, and not in the finer aspects of computer science. I
have a longer rant about using wysiwyg (what you see is what you get) text
programs (like Micro$oft Word), but that is further down the road. For
now, all I want to do is help you see unix as a way to get you out of this
graduate program sooner.
When I first arrived on Princeton's campus, I knew next to nothing about
main-frame computing. A slightly obsessive personality disorder brought me
to my current state, but in the end I realized that it only takes a few
little tricks to make unix much less intimidating. So, off we go.
telnet to arizona.princeton.edu
Step 1: Getting the basic commands
Go to this
Getting Started with Unix, a guide by Princeton's
Data and Statistical Services, and print it out. The commands that you
will use most are in the headings Files and Directories. Note that there's
only 5 or 6 in each category -- not so much to learn after all. Keep this
list handy as you go through the rest of the steps below.
Note that I will follow standard computerese manual conventions below:
terminal input and output will be in courier type , the Unix
prompt will be given by %, variables like username, filename
and filename.sfx will appear in italics.
I also assume that you have a working knowledge of either the Windows NT
H drive, or of ftp (file transfer protocol) programs. If you have not
already done so, I suggest taking the time to read Julian and Kieran's
The Computer and You handout, which is an excellent resource.
Step 2: Changing your shell
Most of the information on this page is of the sort that you should read
once, and then purge from your short term memory. In addition, the steps
which follow only have to be followed once, and then you're on your way to
happier unix computing. I'm trying to include only enough explanations to
give you some confidence that you're not actually about to erase the
directory that has your dissertation. If you really want a more detailed
explanation as to the whys and wherefores of shells and such, there are
several books you can consult when you get a free weekend.
Unix comes in several flavors, which we refer to as "shells." There's the
standard C shell, its more powerful cousin the T shell, bash, and others.
Most standard unix configurations set you up with the C shell, and this is
what we're going to change first. We want the T shell, which will give us
a lot more elbow room -- room that most of us won't necessarily notice, but
that's part of the whole point of it.
To find out what shell you currently have, type
% chsh
which means "change shell". You will be prompted for your
password. After you give it, you'll probably see
Changing shell for username on diskfarm
Old shell: /usr/princeton/bin/csh
New shell (? for help):
This means that you are using the C shell. We want to change this, so at
this point, type in
/usr/princeton/bin/tcsh
You're now on your way. One of the immediate benefits of changing your
shell is that you can recall previous unix commands with the up and down
arrow keys. It's the little pleasures in life ...
(Note to those outside of Princeton:
the usr/princeton/bin/tcsh response is specific to
Princeton's system.
To determine the correct response for your own system, type the
following command
% which tcsh
If you get some sort of error message, then the T shell is not
available. Sorry!)
Step 3: Changing shell environment settings
Every time that you login to your account, the mainframe looks in two
hidden files for environment variables. Think of these as your account
preferences. Your account came with standard versions of
.cshrc (or "C shell resources") and
.login files. They're referred to as hidden files
because their names begin with a period. The standard ls
command won't show them in your directory, but ls -a (or
"list all") will. Unix will read the .cshrc before the
.login file, which (again) you won't really need to
remember after you read this section.
If you are running the T shell, unix will first look for a
.tcshrc file, and will read the .cshrc file
only if it can't find it. Let's leave the .cshrc file
alone, and create a new .tcshrc file. This will help define
some of your new T shell toys.
Save this file in the top level of your H drive
account (assuming, as apparently I must these days, that you're working on
a Windows NT machine and not a Macintosh), or somewhere on the hard drive
where you can find it later and ftp it.
Now go into the top level of your unix account and type
% ls
to make sure it got there. If it did, change its name (or, in unix
parlance, "move" it) with the following:
% mv tcshrc.txt .tcshrc
Now we're going to take something out of your .login file.
Using your favorite text editor, go in there and remove the line that
begins set prompt . The same line appears in the
.tcshrc / .cshrc files, and it doesn't belong in
.login .
Trust me.
Once you've made this change, type
% source .tcshrc
You only have to do this for this session -- normally the file will be read
when you login. You should have received the following error message
/u/username/.aliases: No such file or directory.
but we'll take care of that in a moment.
You should see an immediate change in your prompt, hopefully one that
you'll agree is for the better. Change to one of your lower directories,
and you'll see how useful it can be.
Besides having access to your previous commands, you now have the amazing
abilities to
- mispell a command and be prompted for the correct spelling
- use the tab key to complete the spelling of directory and file
names
- use the backspace key without getting garbage on the screen
- and so much more!
Well, maybe not a lot more, but you're now a lot better off than you were
15 minutes ago. For more information on how the T shell differs from the
C shell, you can take a look at the first two pages of its
manual. (You can also consult this manual anytime by typing
% man tcsh
but note that the manual is fifty-some pages long.) It's possible that you
won't have all of this available to you right away. At this point, you
might as well logout and login again. That should set everything
straight.
DO NOT DELETE your old .cshrc file !!! If you have ever
made any changes to this file, or if any or your geek friends have
helped you in the past, you may now need transfer some of these
commands to your new .tschrc file. Let me know, and I'll
help you go through the .cshrc file to see what's in there
that you need.
Step 4: Adding aliases
You can further increase your unix pleasure to pain ratio if you put
this file into the top directory of your account.
Now change its name with
% mv aliases.txt .aliases
An alias is simply a command definition. If you now type
% source .aliases
(or)
% sou[tab] .ali[tab]
(taking advantage of your new skills) you will read them into your account.
Again, you don't have to do this for every session.
Now that you have your aliases, you might want to know more about what
they are and what they do. Aliases define commands, and can do this
in one of two ways. First, they can create a new command name that
unix wouldn't normally recognize. For example, in the
aliases.txt file, I create a new command called
" m " which invokes the e-mail program pine:
alias m /usr/princeton/bin/pine.396 -l -z
(The -l flag tells pine to automatically expand the folder
collection, and the -z flag allows me to "suspend" the
program, which I'll explain some other time.) Note that this is the
old version of pine, which I prefer. Princeton changed to the newer
version a year ago or so. If you like the new version, you could use
this alias instead:
alias m /usr/princeton/bin/pine -l -z
You can change the aliases anytime you want by editing the
.aliases file. To do so, you could use the " p "
alias, which now stands for " pico ", and type
% p .ali[tab]
As you might have figured out, one of the goals here is to type less,
but get more done.
The second way you can use an alias is to change the default behaviour
of the command, keeping its original name. For example, when I use the
program dvips , which transforms .dvi files into .ps files,
I want to always use the flags -o and -N0 . Since
I can barely remember the exact syntax of these flags, and can't think
of any instance when I wouldn't want to use them, I just redefined the
command with
alias dvips /usr/princeton/bin/dvips -o -N0
If I ever wanted the original, unaliased command, I could type
% unalias dvips
to restore it to default settings. Take a look at the
aliases.txt once again to see what's in there. If you see an alias for
a command that you don't know, don't worry about it. You can delete it if
you want, but I would suggest that you just leave it unless you have a good
reason to dump it. (One good reason might be that you want to use the
alias "j" for something else, for example.) The printer commands in the
last section are specific not only to Princeton, but (in general) also
to the Department of Sociology, and will probably be either the most
useful or the most worthless commands.
(Note to those outside of Princeton:
these aliases are based on specific locations of the files within
Princeton's unix system.
To find them on your own system, type the following commands
% unalias command
% which command
and replace as needed in the .aliases file.)
Step 5: Adding a couple of scripts
Now there's just one last thing to do, which will help you later with file
and directory management. I want you to add two little scripts to your
account, which will allow you to monitor the size of your
directories. (Unlike Windows and Macintosh Operating Systems, you
won't be able to automatically see how large your directory is when
you ls your files.)
First, we make a new hidden directory in the top level of your account
(also known as your "root"), and name it .bin . With your
new prompt, you should know that you're in the top level if the only
thing you see in your path is " ~ ". If you're not there,
then get there with
% cd
Now make the new directory called ".bin" with
% mkdir .bin
Now save / ftp the following two files,
filesize.txt and
dirsize.txt in this new directory. Now change their names (sorry
-- you have to do this because of Windows, not Unix ! ) with the
following
% cd ~/.bin
% mv filesize.txt filesize
% mv dirsize.txt dirsize
% cd
Your .aliases file already contains aliases to these two
scripts. If you were to now type
% dirsize
you would create a few named dirsize.txt in your account.
This contains the size, in kilobytes, of every directory you have.
(And the filesize script will also tell you the size of
every file within those folders.) Anything that is over 1000 is over
1 megabyte. When you run into quota problems, and someday you will,
these two scripts will help you figure out what to remove or compress.
Note that these are simply snapshot text files -- they won't update
themselves as you remove or add things. Running the
filesize and dirsize commands again will overwrite the
text files, and you can remove them any time that you want.
Step 6: Watch your quota !!
When your account was set up by CIT, you were given a "quota" of 10
megabytes. This is enough for your to save some messages in your
e-mail account, and to create a few Word documents, but once you start
doing some data analysis you'll find that you can quickly exceed your
alloted memory.
If you exceed your quota, you have seven days to remove some files.
If you do not do this, you will no longer receive any e-mail, and CIT will
remove some files for you. This is a very bad situation to be in.
If you exceed your quota, you will receive a message about this
every time that you log in. Unfortunately, most people ignore this
message. In a panic, they often then begin removing files in a mad
dash once they figure out that they only have an hour until their
account is about to be altered. Here's some steps you can take to
avoid these perils:
- Put the following line at the bottom of your .login
file:
quota -v
This will show you your quota everytime that you log in. You can also
type this command anytime during your session to see what you have.
- Run the dirsize command (see
above) at least once a week to monitor the
size of your directories.
- Delete messages in your e-mail account that include unnecessary
attachments. If you want to hold onto them, then you should
consider saving the attachment as a separate file in your Unix
account, and then " compress " them (see below). You
should especially look in any " sent-mail " folders that
you might have. If you have sent someone an attachment of a file
that already lives in your Unix account, then you are now saving a
duplicate copy of it in your mail directories -- delete those
messages, too.
- "compress " any large files, especially data sets,
that you are not currently using. You can do this with
% compress filename.sfx
This will replace filename.sfx with
filename.sfx.Z . You can always
" uncompress " this file when you need to use it again,
with
% uncompress filename.sfx.Z
If you have a lot of files in a particular directory that you are not using,
then you can type
% compress *
The asterisk ( * ) is a "wildcard" character -- it refers
to any string that might appear in a filename for the particular
directory you're working in. You could, for example, uncompress
all .Z files with
% uncompress *.Z
- If you have done all of the above, but you are still over (or
near) your quota, then you should get it increased. The department
gets charged for this, so don't go overboard, but you should
certainly get enough to do your work. Cindy will fill out the
paperwork for you, and specify a dollar amount. (She usually
writes in $1,000. This is how much the department is willing to
pay for your Unix needs. And you thought they didn't love you.)
Take this form to CIT, at 87 Prospect, and tell them how many
megabytes you want for your quota. Again, you don't have to jump
to 200 megabytes -- with Cindy's form on file, you can always
increase your quota later when your needs increase. And they will.
-
If you ignored items 1 through 5, and files in your account were
indiscriminately deleted by our friends in CIT, do not panic. First, you
should clean up what does remain, by deleting and compressing. Then you
should send an e-mail to
restores@princeton.edu and ask that the files in question be brought
back to life. CIT backs up every file on every Unix account every night,
and saves them on tape for one year. If you should happen to delete an
important file or directory from your account, you can specify the
filename / directory name and the day that it last appeared in the
version you want, and within a day it will reappear.
And that's all for now. If any of this didn't work for you, or if you
have any suggestions on improving the information or setup that I
describe, please
let me know right away. (And you can even let me know
that it did work, and that you can't wait to learn more...)
Home
|
Research
|
Computing
|
Recreation
Princeton University
|
Sociology Department
|
Graduate Students
posted 15 November, 1999
cupright@princeton.edu