Basic of Unix
Basic of Unix
Basic of Unix
You should read through this section, ideally sitting in front of a terminal so you can try out the
various commands.
4.1 Introduction
The Unix operating system is accessed partly through the X-Window interface and partly
through Terminal Window into which you type commands. This section covers the basic U NIX
commands that you will need to use in the Terminal Window.
[/]
CheckPoint1.java CheckPoint2.java
For example the file that contained the source code for the solution to your first checkpoint may
be located in:
/Home/s0312345/sci-prog/checkpoints/CheckPoint1.java
/usr/java/bin/javac
The structure is divided into user and system files, being the files that belong to the users of the
system and the files that are part of the general system. On this system the users file are under
/Home, while the system one are mostly under /usr (the name is historical!).
/Home/s0312345
This is known as your home directory. All files below this directory belong to you, and you can
do anything to them, (read, write, delete etc.).
Path Names
Filenames can either be absolute, where the file names defines the whole path from the system
root (/) directory. Such filenames start with (/) as above. Alternatively filenames can be
relative to where “you are” in the file structure. In this case the name does not have a leading
(/).
For example, if your username is s0312345 then when you login the terminal screen is initially
in your home directory, being /Home/s0312345. This is called your present working directory.
So when in this directory the file checkpoint1.c can be referred to as either:
/Home/s0312345/sci-prog/checkpoints/CheckPoint1.java
or
sci-prog/checkpoints/CheckPoint1.java
where the first example is its absolute name and the second is its name relative to your present
working directory.
This all sounds rather complex, but is actually very intuitive once you have tried it out for
yourself!
1. Directories or files names that start with a dot (“.”) are called hidden. These will not
appear on normal directory listings, see below. Such files are normally used to hold user
options to various applications.
2. Most filenames are of the form <basename>.<extn> where <extn> is used to specify
the type of information in the file.
3. It is possible to use other punctuation characters but they can clash with wild-card char-
acters and other special characters, so should be avoided.
more Fred.java
If the file Fred.java is longer than the current terminal screen the following keys come into
play, these being.
S PACE Forward one screen
D Forward half screen
R ETURN Forward one line
B Back one screen
H Rather cryptic help screen
Q Quit
Plain text files can be printed using
lp <filename>
where <filename> is the name of the file to be printed. This printer is free and useful for short
program listings.
If using the CPLab L INUX this will appear on the laser printer in the CPLab, if using the remote
connection via the Microlab, this will appear on the EUCS “lineprinter” in room 3305.
4.10 E-Mail
You do not have a seperate E- MAIL account on this system. You sould continue to use your
University SMS account which is available through M OZILLA.
man pages
All U NIX commands, most applications and most functions are all documented via the on-line
system manual pages. These are very complete, usually being written by the actual programmer
who implemented the command or application. As a result they usually assume a level of
knowledge about the system well above that possessed by the average (never mind the novice)
user. The quality, readability and length of man pages is very variable, however they do usually
contain the correct information!
The man pages are accessed by,
• Type man <command> in the terminal window. For example to get the man page for ls
you simply type man ls. This will output the manual page to the terminal window one
page at a time with the same page commands as more (see above).
1. CP Lab “on-line” H ELP pages, link from Scientific Programming Home Page.
2. On-line via the U NIX H ELP pages written and maintained by the E DINBURGH C OMPUT-
ING S ERVICE (ECS). Link from Scientific Programming Home Page.
4. Any and varied books on U NIX in the library and for purchase in bookshops.
Note: There are many “flavours” and “dialects” of U NIX which are superficially similar but
with subtle and annoying differences. These differences mainly show-up in the system manage-
ment tools which most users never need or use. For each system the definitive documentation
is located in the man pages!
What Next?
Now you have some practice of using the basic U NIX commands you should now read the next
section on the emacs editor. You will need to use this to write your first JAVA program.