How about a short Unix Primer?
My pleasure.
Unix is a very powerful and stable operating system.
It has many tools that can be used to
customize your environment to suit your working
style -- and with some basic programming ability,
you can also program many of these tools yourself.
It has plenty of software
(called Unix tools) that are free and contributed by other
users and programmers like yourself. Unix was invented
by Thompson and Ritchie from Bell Labs in the late 1960's.
Its original multi-user operating system is something that
Windows NT is trying to emulate in the 1990's.
There is another reason to know Unix: there is a
free version called LINUX that you can even download
from the internet, and it comes with loads of free
software! However, the simplest way to get LINUX
on your home machine is buy a book on LINUX that also has
a distribution of LINUX on a CDROM.
Your basic interaction with the Unix operating system
is through a program called the "(unix) shell".
There are several variants of very powerful command
languages ("sh", "bash", "csh", etc) that
allows you to program this shell.
Here are some basic shell commands (we suggest
that you try out them out as you go).
NOTATION: when specifying commands below,
<xxx> indicates a string to be replaced by actual arguments.
However, [xxx] indicates an optional argument xxx.
BASIC SHELL COMMANDS:
- logout or exit: exit Unix. Always know how to
exit a system you are in.
- ls [dirname]: listing files in directory "dirname".
This helps you see what files are out there.
- cd [dirname]: change current directory to "dirname".
- pwd: print the name of the current (working) directory
- man <command>: most useful general command to learn!
This gives you the online manual page for
<command>. For instance, you can find out
more about each of the commands in this list by
doing "man" of that command. Most of the commands
below have lots of options that we do not mention.
- mkdir <dirname>: create a new directory named
<dirname>.
- more <filename>:
display contents of <filename>
by the screenful (type <space> to get next screen,
type <escape> to quit).
- lpr <filename>: print file to default
printer. On some version of Unix, you use "lp" instead of "lpr".
- printenv:
Gives you the list of your
environment variables
and their current values.
If you want to print just the value of the environment variable
PATH, then simply type printenv PATH.
- setenv <var name> <new value> :
command to set the environment variable
< var name> to the value <new value>.
DIRECTORIES AND SPECIAL DIRECTORY NAMES
Many of the above commands refer to file names
and directories. How are these organized?
All files in unix are stored in directories.
A directory can contain other directories
("subdirectories").
All these files and directories are organized as a tree.
The root of this tree is a directory called
the root directory and written "/".
Type this command to see what is in root directory:
ls /
The output of the command will include standard
subdirectories named "usr", "bin", etc.
If you want to see what is in "bin", you can next type
ls /bin
Every user in a unix system is given a
home directory.
For instance, on my unix account, my home directory
is named "/home/yap".
Unix gives you a short way to refer to your home directory:
it is "~" (tilde character).
In fact, you can refer to any other user's
home directory by appending the user name to tilde.
Thus, if someone has user name "jane", then
jane's home directory can be referred to as ~~jane".
When you log into your account, this will be your initial
current directory.
Of course, the current directory can be changed
by using the cd command.
Again, you can find out what your current directory
name is by typing the command pwd.
A short way to refer to your
current directory is "." (dot character).
Likewise, a short way to refer to
the parent of current directory
is ".." (dot dot characters).
E.g., the grandparent of current directory is "../..".
Try this out: if your current directory is the root "/",
and you type the command ls .., what do you get?
E.g., you can list the files in your grandparent directory
by typing ls ../...
E.g., If your parent directory has a subdirectory named
"foo", you can make foo your current directory by
typing cd ../foo
SPECIAL KEYS
Important and useful to know:
- CONTROL-C: aborts the current job.
(definitely superior to the "reboot" of Windows).
- CONTROL-Z: suspends the current job. This is
less drastic than CONTROL-C.
You can resume this job by typing "fg" (=foreground).
Or, you can put this job in the background
by typing "bg" (=background). Thus, you can
have as many background jobs as you like!
- CONTROL-D: kills the command shell (usually
equivalent to logging out).
What else should I know in unix?
-
Text Editors:
this is probably the most basic tool you need next.
For instance, you need this to create your program files
or prepare your research papers.
-
Text Processing:
Most Unix users prefer TeX or LaTeX for preparing their
documents. Especially for mathematical typography, this
is unequalled.
-
Shell:
Actually, you talk to unix through a special
command called a "shell". The "shell" is actually
a command interpreter and it has its own
syntax which you program...