The Quickest and Dirtiest Introduction to UNIX Ever
Introduction
This is just stuff off the top of my head - it is in no way
complete, but will hopefully allow you to get started. If you have any
suggestions for this document, or you notice any errors or omissions,
or pitiful bad grammar talking stuff just send me an email message or stop
by my office.
Some things are specific to watarts - things may work slightly different
on other UNIX systems. Anyway, again, it's nothing fancy, but hopefully
enough to get your started. If you make a printout, be sure to check
this on-line version ocassionally to see if there are any changes/additions.
Files
UNIX filenames can be up to 255 characters.
In order to stay out of trouble, a good rule of thumb is to create
filenames using only letters (a..zA..Z), numbers (0..9) and a period
(.) in order to make a filename more readable (it's probably a good
idea to not include spaces in filenames.
As well, stay away from characters such as:
+"'`~-?*&(){}/\$#!<>*,;:[]
which only complicate things.
Also, file names in UNIX are case sensitive, as opposed to
case-insensitive as they are on Windows machines. This can be a cause
for confusion at times. [Lucas Cherkewski, 2012]
So, a valid filename
might be something like 'this.is.a.very.long.name.for.a.file'
- although you probably will use
simpler filenames. UNIX also allows the creation and use of
subdirectories much like MSDOS and similar to the Mac folders and
subfolders.
Everyday Commands
Here's some of the more common commands you might use on a
daily basis. Try each of them to see what happens (but be careful with
rm(1)). All the manual pages for these commands are online - see the
section 'Online Manual Pages' below. If I use something like 'rm(1)',
it means that you can look at the online manual page for the command by
typing 'man 1 rm', which will show you the documentation for
the 'rm' command in section 1 of the online manual pages. Normally when
explaining the commands, I'll surround the command in single quotes "'"
- the single quotes aren't part of the command, so don't type them when
you are trying things out.
-
lc(1)
- list the contents of the current directory.
-
ls(1)
- another way of listing the files in a directory.
You can also try 'ls -al' to list all the files in
the current directory in a long format the -al are options to specify
'all' and 'long'. This is typically of most UNIX commands -
options are specified after a '-'.
-
cp(1)
- is used to copy a file.
'cp file1 file2' would make a copy of file1 and call it file2
(file1 would be left unchanged). In addition, cp will also let
you copy entire directory structures. You probably don't want to try
this now, but if you had a directory called 'dir1' with millions
of files and subdirectories in the directory 'dir1', you could
make a copy of it by typing 'cp -r dir1 dir2' which would
name the new directory 'dir2'. The -r options means to
recursively go through the directory copying all files and
subdirectories which it finds.
-
mv(1)
- is used to move a file to another directory or to
rename a file. For instance, 'mv file1 file2' would
change the name of 'file1' to 'file2'. If there was
already a file named 'file2', it would be replaced with the new
file.
-
rm(1)
- removes or deletes files. For instance 'rm file1
would delete the file named 'file1' from the
current directory. You probably don't want to try this now,
but you can also remove an entire directory structure with something
like 'rm -r dir1' which would remove the directory 'dir1'
and all files and subdirectories in it without question. Just so
you don't get yourself in too much trouble, I should mention that UNIX
uses filename wildcards in a similar way as DOS. So if you did
something like 'rm *' (DON'T DO THIS), it would remove all
the files in the current directory. Rm has a -i option (interactive)
which prompts you for a yes/no response before it removes a filea. For
instance, 'rm -i temp' would ask you to enter 'y' or
'n' in order to confirm the removal of the file. In the same way
'rm -i *' would ask for a confirmation before each file is
removed. Removed files and directories CAN NOT be unremoved on a UNIX
system. If a file or directory was backed up on tape, it could be
restored, but if you create a file and 5 minutes later you remove it,
then it's gone...
-
mkdir(1)
- allow you to make a directory. For instance,
'mkdir dir1' would make the directory 'dir1' in the
current directory. You can use lc(1) to see what directories exist
after you try this.
-
rmdir(1)
- allows you to remove a directory. The
directory must be empty (no files or other subdirectories in
it) in order for rmdir to work. For instance 'rmdir dir1'
would remove the directory 'dir1' if that directory
were empty.
-
cd(1)
- allows you to change directories. For instance,
cd dir1' would change to the 'dir1'
directory. You can type 'cd' with no directory
name which will always bring you back to your home directory
(the place you started when you first logged in).
-
more(1)
- displays a text file one page at a time. For
instance, if you type 'more .cshrc' to view the file
.cshrc in your home directory, you will see the first
screenfull of lines with the word '--MORE--' in the bottom left corner.
The '--MORE--' means that there is more text available - you can simply
press the spacebar for the next page, the [return] key for the next
line, or the 'q' key to quit. You can also press the '?'
key to get a list of available options. The more program is used in
many places (such as mail and the online manual pages), so you will
quickly become familiar with it.
-
passwd(1)
- allows you to change your login password.
-
acs(1)
- typing 'acs' will display the
accounting information about your userid (this command is specific to
watarts). You should probably check
this information every few weeks at least...
-
finger(1)
- allows you to lookup information on a user.
Usually you'll need to specify the userid of the person you would like
information on (eg. 'finger bee@watarts), but on most unix
machines, you can specify a first or last name which should achieve the same
results (eg. 'finger eickmeier@watarts). If you would like
to change the information which finger provides for your userid,
type 'chfn' and answer the questions.
-
spell(1)
- allows you to spell check a file. Simply type
'spell filename' (where 'filename' is the document
you'd like to spell check). Words that neither occur among nor are
derivable (by applying certain inflections, prefixes or suffixes) from
words in the spelling list are printed to the screen. Be sure to use
'spell -b' for British spelling.
-
webster(1)
and
oed(1)
- are used to look up words in
online dictionaries. In the simpliest form, you can type
something like 'webster word' or 'oed word' at the
unix prompt to get the definition of a word.
Watarts also has a command called
files(1)
which is a full-screen file
manager for UNIX. It seems pretty easy to use and will let you do many
simple file manipulations quite easily. You can start it up by typing
'files' at the UNIX prompt. Be sure to try it if you are new
to UNIX - it may initially make things easy for you until you learn how
to do things from the command line. I wouldn't recommend though
it if you plan on doing 'real' work...
Sending and Receiving Email
The simplest email program under UNIX is
pine(1).
To start the
pine(1) program, simply type 'pine' at the UNIX
prompt. The available options are listed on the screen for you to
choose from - it's pretty straightforward but doesn't have the features
of some other mail programs. If you'd like to experiment sending and
receiving email, feel free to send mail to me, my email is
bee@uwaterloo.ca. Pine keeps a menu at the bottom of each screen so you know
exactly what commands are currently available - you can just press the
corresponding letter to select the desired option. The only piece of
magic to remember is that if you see something like '^X', it
means to hold down the 'Ctrl' key and press the 'x' key.
Other popular mail programs available under UNIX are
mail(1)
and
elm(1).
Text Editors
There are a bunch of different text editors available
under UNIX. The simplest text editor running on watarts is the
pico(1)
editor (pine actually uses the pico editor by default when you are
composing an email message). To start the editor, specify the name of
the file you want to edit on the UNIX command line, by typing something
like 'pico temp' which will start up the pico editor editing
the file 'temp' (if the file 'temp' doesn't exist, a new
empty file is created).
Pico(1) also lists the available options on the screen in the
same way as the pine(1) mail program. The option '^X' means
that you should hold down the 'Ctrl' key and press the 'x' key.
Most of the options require you to use the control key.
Another more powerful editor is the
vi(1)
editor. Vi(1) is not
quite as user-friendly as the pico(1) editor - the available commands
are not listed on the screen. You should probably have a vi(1) manual
or helpsheet beside you before you try using it. The vi(i) editor is
much more powerful than the pico(1) editor, but the pico(1) editor is
probably a better choice for the beginner. You probably want to learn
vi(1) later if you plan on doing programming or a lot of text editing
under UNIX. I have an online vi(1) tutorial which can be installed on
your account if you'd like to learn it. As well, my WWW page (see below)
various documentation on vi.
Online Manual Pages
There's a program called
man(1)
on UNIX which gives you access
to all the UNIX commands available. For instance, to find out about the
ls command, you could type 'man ls. You will see the first
page of the description for ls with the word '--MORE--' in the bottom
left corner. This means that there is more text available - you can
simply press the spacebar for the next page, the [return] key for the
next line, or the 'q' key to quit. You can also press the
'?' key to get a list of available options.
A very useful feature of the online manual pages is the ability
to look up keywords. You'll notice that each manual page has a one line
description of the command it is describing. These one line
descriptions can be searched using man(1)'s '-k' option. For instance,
typing 'man -k mail' would display the names of all manual
pages with the word 'mail' in the one line description. Be sure to
use this excessively!!!
Printing Files
By default, anything you print on watarts will be sent to the
ACO
printers in PAS 1099. At the unix command line, you'll probably
use the
lpr(1)
command to print a file. For instance,
'lpr myfile' would do the obvious. Your request to print the
file called 'myfile' will go down to the ACO printers - in the
printer room you will need to enter your userid and password in order
to have the printer actually print your stuff. You may also print stuff
directly to the Psychology Department's laser printers - there's a
charge for this and we'll need to set up the accounting to allow you to
print, so please see me if you'd like to do this. It's also possible to
print to a printer attached directly to the computer you're working on
- it depends on your setup so ask me about it.
WWW
There is a huge amount of information available
on the World Wide Web (WWW) accessible with
programs such as
Netscape(1)
and
lynx(1).
I can't begin to describe
all the information available with these program, you are just going to
have to try them.
Netscape is a much more powerful way of accessing information. With Netscape
you can view text, graphics
images, animations and even listen to sound files if you are at a
machine which can support these. On most PC's with Windows and Mac's
connected to the network in the department, you should be able to find
an icon called 'Netscape' which you can just double-click on in order to
fire it up. From a watstar account you can also start up Netscape from
Windows. You can also run Netscape from the Xterminals in PAS 1080.
If you are starting it from the UNIX prompt, just type 'netscape &'
in order to fire it up.
You should look at Netscape at least once to see what is available.
Anyway, once you've started Netscape, you can use the mouse to
single click on any highlighted phase in order to access the
information it links to.
Lynx is a plain text version of Netscape - you'll want to run this
you are at a plain terminal which doesn't support graphics or sound.
Just type 'lynx &' to start it and press 'h' for help.
I've set up a WWW (World Wide Web) page called the "beeHive" (I tried
changing the name, but people made me change it back) which contains a
lot of information relevant to people in our department. There's
various psychology related items and lot of information on the use of
PC's, Mac's and UNIX machines as well as information available from
IST.
On most machines in the department, this is probably the default
starting point for Netscape or Lynx. In case it's not on the machine
you happen to be using, you just need to open the WWW URL
http://watarts.uwaterloo.ca/~bee/
Network News
There's currently more than 8,000 newsgroups worldwide. There's
a number of ways of accessing these newsgroups. The most efficient
newsreader is probably
trn(1).
Check my WWW page for a tutorial
on using trn. There's some magic to using trn efficiently so
feel free to ask.
Another more straightforward newsreader is called
tin(1).
Currently
it's not installed on watarts, but I've compiled my own version
which you can access by typing '/u/bee/bin/tin' (you'll
get a message once the ACO has installed the official version).
Tin is very easy to use - just press the cursor keys to navigate.
There's always a menu of commands at the bottom of each screen listing the
available options.
As well, it is possible to set up Pine to read the network news
as well as email messages. If you'd like to use it in this
way, stop by my office for a moment - I'll need to change a few
of your startup files to allow you to do this. Using pine for
reading news is a good choice since you probably are already
familiar with it and it's easy to use.
Transferring Files To and From Pc's and Mac's
For PC's running Windows, the easiest program to use to transfer
files to and from a UNIX machine is
Rapid Filer.
Essentially you
just enter the name of the machine you want to connect to (usually watarts)
along with your userid and password. Two windows will appear, one the
DOS file system and the other the unix filesystem. You can simply
drag a file or directory icon from one window to the other in order
transfer it to the other machine.
On Mac's, use
Fetch.
You simply enter the name of the machine you want
to connect to along with your userid and password and simply specify
the files or directories you want to put or get from the other machine.
If you are connecting from a UNIX machine to another UNIX machine,
you'll probably use a program called
ftp(1).
Essentially, you might do something like this to transfer
a text file called 'myfile' from your machine to a remote machine:
ftp remote.machine.name
- and enter your userid and password at the prompts
dir
- if you want to list the files on the remote machine
put thefile
- which will put the file (use 'get' to get a file)
quit
FTP assumes you are transferring a plain ascii text file by default.
Binary files (non-text files) such as word processing documents,
or compressed files (zip, gz, etc) need to be treated specially.
A good rule of thumb before getting or putting a file, is to either
enter the word 'ascii' or 'binary' depending on the type of files
you are transferring.
Most importantly,
type 'help' at the ftp prompt for a list
of command which are available.
The above is in no way a complete description of FTP.
The beeHive also has a tutorial
for using ftp which you might want to check out.
Other Stuff
At some point, you might want to ask about other useful programs such
as
calendar(1),
awk(1),
grep(1)
and
screen(1)
- or just check the online man pages yourself at your leisure
IST
also provides
courses
on various UNIX topics throughout each term.
These are announced in several places including the IST Newsletter and
through Lynx or Netscape.
I suppose the most important thing to remember is that if something
seems difficult, there's probably an easier way of doing it. There are
a lot of powerful tools available under under UNIX, but because there
are so many, it's sometimes tough to figure out exactly what will best
do the job for you. Just ask and I'll try to get you moving in the
right direction...
See Also
Here's a few more links of interest:
Jump to
- beeHive
- UW Psychology
- UWInfo Home Page.
Last update: June 1996,
bee@uwaterloo.ca