This tutorial covers the basics of using the Linux operating system from the command line. An operating system is the suite of programs that make everything else on a computer work. Linux is patterned after an earlier set of systems collectively referred to as UNIX, and so Linux will often be desribed as a UNIX system.
When you are sitting at the computer's console, the X Window System and programs built on top of it provide you with a graphical user interface. There are many things, however, for which you will need to use the text-only command interface. You can also easily use the command-line interface when you are connected remotely over a secure shell (SSH) session.
The UNIX operating system is made up of three parts; the kernel, the shell and other programs.
The kernel of UNIX is the hub of the operating system: it allocates time and memory to programs and handles the filestore and communications in response to system calls.
As an illustration of the way that the shell and the kernel work together,
suppose a user types rm myfile
(which has the effect of removing
the file myfile
). The shell searches the filestore for the
file containing the program rm
, and then requests the kernel, through
system calls, to execute the program rm
on myfile
. When the process
rm myfile
has finished running, the shell again
presents its prompt $
to the user, indicating that it is
waiting for further commands.
The shell acts as an interface between the user and the kernel. When a user
logs in, the login program checks the username and password, and then starts
another program called the shell. The shell is a command line interpreter (CLI).
It interprets the commands the user types in and arranges for them to be carried
out. The commands are themselves programs: when they terminate, the shell gives
the user another prompt ($
on our systems).
The adept user can customise his/her own shell, and users can use different
shells on the same machine. Staff and students in the CS lab have
the shell bash
by default.
bash
has several features to help the user entering
commands.
[Delete]
key to delete a character and back up. Less
obviously, you can use the forward- and back-arrow keys to move
around within a line; you can type other characters to insert
them at the current position. A few other useful characters:
The number of other programs available is mind-boggling. But you can do lots of useful things efficiently if you learn the basics of a handful of standard programs, which is what the rest of this tutorial will teach you.
Everything in UNIX is either a file or a process.
A process is an executing program identified by a unique PID (process identifier).
A file is a collection of data. They are created by users using text editors, running compilers etc.
Examples of files:
All the files are grouped together in the directory structure. The file-system
is arranged in a hierarchical structure, like an inverted tree. The top of the
hierarchy is traditionally called root. Each user has
a personal directory called the home directory; on our
systems the home directories are in a directory named
home
that is, in turn, found in the root directory.
In the diagram above, we see that the directory
snerdm
contains a file proj.txt
and a subdirectory tutorial
.
When you log in on the console, you'll see your
desktop. If you type [Ctrl][Alt]T (that is, while holding
down the keys marked Ctrl
and Alt
, hit
T
). That should produce a Terminal window that looks
something like this:
That shows you a shell prompt, waiting for you to type a command. You might notice that the prompt contains three pieces of information: a username, the name of the computer, and the current directory.
If the Terminal program was not already in your dock, you can add it so that it will be easier to launch it in the future: right click on the Terminal icon in the dock and select “Add to Favorites”.
M.Stonebank@surrey.ac.uk, © 9th October 2000