ENOUGH UNIX TO GET YOU BY

It isn't my intention to create unix wizards overnight. I'm not one
myself! However, a bit of knowledge can be (in addition to a dangerous
thing) useful, and you'll likely fine the unix command line easier to
use than the menus once you get the hang of it.

Some basic things to remember:

1. Case is important. cd is not the same as CD. Most unix commands are
lower case.

2. Unix is terse. You'll rarely get feedback as to the progress of a
command.

3. Unix is flexible. Switches can be used to change the way most
commands operate.

4. Online help is available. The "man pages" for most commands will
give you hints and descriptions. There is one fake man page. Can
you guess what it is?

5. You must leave a space between the command and any switches or
arguments.


DIRECTORY STRUCTURE

Initially you are placed in your "home" directory. This is a
subdirectory of others with your username as the last branch of the
tree, something like /users/users1/you.

Directory commands:

pwd displays present working directory

cd Change directory. Without any argument, returns to your home
directory. cd / takes you to the top (root) directory. cd ..
moves you up one level.

mkdir Make a new directory.

rmdir remove a directory.


FILE MANIPULATION

Many things that you don't think of as files actually are treated as
files. A directory is a special kind of file. The connection to your
screen, called a tty from the old teletype days, is a file. Many of the
unix commands you'll use deal with manipulating files.

File manipulation commands:

ls List files. Gives a listing of files in the current
directory.

-l long. Gives more detail about the files.

-a all. Include "hidden" files.

-t time. Sorts in order of time saved, most recent first.

-F Full. Shows detail about file type. /=directory, *=executable

rm Remove a file.

-i interactive. Ask first for confirmation.

mv Move a file. Can be used to move a file or group of files
into a new directory, or to rename a file.


FILE PERMISSIONS

Each file or directory has the capability of having permissions set as
to access. Obviously, you don't want other people reading your mail or
writing to your directories and using your quota. On the other hand,
you might want a .plan file to be readable by others or to make files
available for ftp or web browsing. Using the -l switch with ls allows
you to see the permissions associated with files. Typically a listing
will look like drwxr-x--x . The first position indicates the type of
file, in this case d for directory. The next three characters show that
the owner of the file (you, if you created it) can Rwad, Write, and
eXecute the file. The next three letters show that members of the
owner's group can Read and eXecute (but not Write) to the file. The
last three letters show that others (the rest of the world) can eXecute
(but not read or write) to the directory. Execute permission on a
directory allows access to the files within the directory, but read
permission is necessary to display the files.

File permissions are changed with the chmod command. Care must be taken
so as not to lock yourself out of a file or directory accidentally.

There are two different formats with which the chmod command can be
used, the easiest and most positive consists of the following syntax:

chmod nnn filename

Where n is a number ranging from 0 to 7, and the positions indicate
owner, group, and all. The number is calculated as follows:

4 = read 2 = write 1 = execute

Just add them up. So, to establish the permissions in the example above
you would type: chmod 751 filename (where filename is the name of the
file or directory).

DISPLAYING FILES

A file (or several files) can be displayed on your screen with the cat
command. If the files are more than a screenful, you had better be a
fast reader, as the file(s) will zip right by.

The more command will also display files, but pauses at the end of each
screen. Hitting the spacebar advances to the next screen.

The less command is similar to more, but also lets you move back and has
a few other enhancements. So, at least in unix, less is more, and even
more than more.

cat file1 file2 file3 conCATenates the files together (and sends them
to the standard output (your screen).

more file1 stops at each screenful.

less file1 works like more, but is more flexible.


REDIRECTION AND PIPES

You can redirect the input to or output from a file by using the keys <
and > . For example, if you have several text files and you want to
combine them into a large one, you can use the redirection symbol to do
this. Example: cat infile1 infile2 infile3 > outfile . This will
conCATenate the three infiles into outfile. You can also use the >
symbol to capture the output of a process to a file. For example, if
you wanted to mail the results of a finger search to someone, you could
type: finger user > finger.txt . This will perform the finger command
and instead of displaying the results on the screen, write the results
to a file named finger.txt. You can then import the file finger.txt
into an e-mail composition.

A pipe is similar to redirection, but pipes the output of one command
through another. For example, we can type: cat file1 file2 file3 | more
and the three files will be concatenated and displayed one screen at a
time.

TRANSFERING FILES

The commands sx, sb, and sz are used to Send Xmodem, Ymodem, and Zmodem
from the host unix system to the remote system (your computer). Don't
ask why it isn't sy instead of sb, I don't know.

Similarly, rx, rb, and rz are used to Receive Xmodem, etc. from your
computer to the unix host.

Zmodem is the most efficient protocol of the three, if your
communications program doesn't support it, you should fine one that
does.

If you have a file on the host system called, for example, foxy.gif and
you want to download it to your home system, you need merely type:
sz foxy.gif and away it goes. You can also use wildcards to speed
repetitive processes. If you have several files that all end in .gif,
you can type sz *.gif and you'll get all such files in your present
directory. Later, you can remove them from the host by typing rm *.gif.

To upload a file from your home system to the host, merely type rz and
then use the software option in your communications program to start a
zmodem upload.

For text files, you may want to convert from DOS format to unix format
and vice-versa. DOS text files use a control-M and a control-J at the
end of each line, whereas unix text files use only the control-J. So,
if you upload a document from your home computer it will probably have
an extraneous ^M at the end of each line. Likewise, if you download
text from the host to your home system, the text may appear jagged and
not print properly. To fix this, use the utilities dos2unix and
unix2dos. Syntax is as follows:

dos2unix infile outfile . This will convert the DOS format infile to
the unix format outfile. You can use the same name if you want, and the
original file will be overwritten with the new one.

Similarly, you can convert a unix text file format to DOS format by
typing unix2dos infile outfile.

There are other ways to do this including option switches for sz and
parameter settings on your communications software, but this will always
work regardless.

OTHER HANDY COMMANDS

finger Gives a listing of who is on the system, when they logged on,
and from where.

finger name Displays info on anyone with the name in their username,
first, or last name.

finger -m
username Displays info on username only.

w displays a listing of who is on and what they are doing.

talk Allows 2 users to chat.

ytalk Enhanced version of talk, allows interactive chat among 2 or
more users.

Control-Z suspends a process so you can do something else (like answer
a talk request).

fg Brings back what you had suspended.

ps Displays what processes you are running (in case you forgot).

Control-L redraws your screen to erase annoying talk requests.

mesg n prevents annoying talk requests from showing up at all.

mesg y allows you to see polite (and annoying) talk requests.

quota -v Shows your disk usage and quota.

du Another display of disk usage.

ping hostname Check to see if a host is alive or reachable.

pico filename Pine-like easy file editor.

Customizing your shell:

There is a file in your home directory called .cshrc that can be
customized to make things easier for you. For example, if you regularly
initiate talk sessions to rumplestiltskin@fairy.tale.legends.edu, you
can create an alias so that when you type "trump" the system thinks you
typed "ytalk rumplestiltskin@fairy.tale.legends.edu". This is called an
alias, and is entered as:

alias trump ytalk rumplestil.... (you get the idea).

You might want to enter the following alias to prevent you from
accidentally erasing files:

alias rm rm -i

This will substitute the interactive version of the rm command.

Also, you'll find that if you change from menus to unix as your default
shell, you'll have the more difficult (but more versatile) vi editor as
your default instead of the easier pico. You can fix this by adding the
following two lines to your .cshrc:

setenv EDITOR 'pico -t'
setenv VISUAL 'pico -t'

That's it for this intro, check out "A Student's Guide to Unix", Unix
Unbound", and "Voodoo Unix" for lots more.

Written by: Floyd Lecureux
lecureux@gaia.ecs.csus.edu


Return to the ECS Home Page