Your instructor will have to tell you how to access your account and how to start up the X Windows System and desktop environment. Unlike Microsoft Windows and Macintosh operating systems, there are several variations of X11 and many different desktop environments built on top of X11. Generally these desktop environments work on the same principles as Microsoft Windows and Macintosh OSs, so let your intuition guide you.
Regardless of what GUI you use on your UNIX machine, you can always interact with UNIX directly with a CLI. Eventually, your instructor should tell you how to open a terminal window (a.k.a., an xterm or a console window).
My terminal window looks like this:
This terminal is from the KDE desktop environment, where it is called a "konsole".
As pictured in this example, I use a two-line prompt:
[localhost:~] $
A UNIX prompt is highly flexible. Yours is probably very simple. The purpose of the UNIX prompt is to prompt you for a command. If you don't see a prompt, the terminal window is busy working on something else.
Question #1.UNIX.01 What does your prompt look
like?
To be answered in Exercise
Questions/lab01.txt
.
For this lab manual, I will use unix-%
as a generic
UNIX prompt. Never, ever type in the UNIX prompt. That's
the prompt from UNIX; you must enter in the command that you see
after the unix-%
prompt.
UNIX interaction consists of three steps which are repeated until you close the terminal window:
The UNIX environment is case-sensitive, and virtually all UNIX commands use lower-case letters. This will cause you a great deal of frustration if you forget it, so keep this in mind.
In order to use a command-line environment, you must learn those commands that the environment understands. Let's first see what happens if you type something that the environment does not recognize.
Do this...
Enter
unix-%
qwerty
For the sake of your own sanity, remember that
unix-%
is the UNIX prompt, so you must not type
it.
Question #1.UNIX.02 How does the system
respond?
To be answered in Exercise
Questions/lab01.txt
.
This is the way that UNIX responds when you give it a command it doesn't understand.
You will create dozens of files as you go through this lab manual, and it's best to keep them organized separately from the other work that you do. Just as the documents (i.e., files) in a filing cabinet are often kept in manila folders, we can create a container in which to keep related files, called a directory (or a folder).
Let's create a new directory.
Do this...
Enter this UNIX command:
unix-%
mkdir courses
After you type in the command, you should get the prompt back. If something goes wrong, then you'll get an error message. But no message means that something was done successfully.
The mkdir
command is the UNIX command to
make a
directory. By placing the word
courses
after the mkdir
command, you tell
the system that you want to make a directory named
courses
.
Do this...
Practice using the mkdir
command to make two
directories in the courses
directory: one named
courses/BOGUS
and one named after the course that
you're taking (e.g., courses/cs108
).
The slash /
character in these directory names is
very important because you're creating directories within a
directory. This allows you to keep the files for this course
separate from other files you might need.
The mkdir
gives no feedback unless something goes
wrong. So how do we know it did anything?
Do this...
Enter
unix-%
ls
The ls
command displays a
listing of the contents of a
directory. If all is well, you'll see at least the
courses
directory. You'll undoubtedly see other
directories and files, but the specifics differ in each type of
UNIX.
But where are those other directories you created? They're
inside the courses
directory. The
ls
command can also be used to find out what is in a
particular directory.
Do this...
Enter this command:
unix-%
ls courses
If you follow the ls
command with the name of a
directory, it displays that contents of that directory. Now you can
see two other directories that you created before.
Question #1.UNIX.03 What ls
command do you need to run to see the contents of the other two
directories (courses/BOGUS
and
courses/cs108
)? They should be empty right now.
To be answered in Exercise
Questions/lab01.txt
.
To get a more detailed listing of the current directory, enter
unix-%
ls -l
The -l
is called a switch or
flag that causes the ls
command to
generate a long (i.e., detailed) listing. The hyphen indicates to
ls
that the l
has a special meaning; it's
not the name of a directory or file. All UNIX commands
have flags like this. If your UNIX has the latest version of
ls
, you can even try this:
unix-%
ls -lh
This will print sizes in a human-readable form. (If the
h
flag doesn't work, don't sweat it.)
I deliberately asked you to create the
courses/BOGUS
directory just so that you'd have a
directory to delete. You can use the rmdir
command to
remove a directory just like
you'd use mkdir
to make a directory.
Whatever directory you specify following the rmdir
command will be removed from the file system, provided that the
directory being removed is empty. To remove a non-empty directory
named DirectoryName
, use
this command:
unix-%
rm -r
DirectoryName
This should only be used when DirectoryName
contains nothing important!
Do this...
Use either the rmdir
or rm -r
commands to
remove the courses/BOGUS
directory.
Using the ls
command, verify that
BOGUS
directory no longer exists.
When you begin a computing session, UNIX always starts you out in your home directory. You do not have to remain in your home directory; you can change to a different directory whenever you like.
The directory in which you are working at any particular time is
called your working directory. To find out the
name of the working directory, you can use the pwd
(print working
directory) command:
unix-%
pwd
Question #1.UNIX.04 What specific output do you
get when you run the pwd
command right now?
To be answered in Exercise
Questions/lab01.txt
.
UNIX systems (like all modern operating systems) utilize what is
called a hierarchical directory system, meaning
that directories can contain other directories. There is one
root directory denoted by /
(a single
forward slash) which is the top directory; all other
directories are directly or indirectly inside this root
directory.
Do this...
Run this command:
unix-%
ls /
This lists the contents of the root directory. Within
/
are a number of subdirectories, including
usr
, bin
, include
, and
home
. Each of these contain other directories and
files. On many UNIX systems, the home directories of the users are
stored within the home
directory. Here is what this
might look like on a particular machine:
UNIX treats the tilde character (~
) as an
abbreviation for your home directory, which can save you a lot of
typing if the path to your home directory has lots of
characters.
If you created all of your files in your home directory, it
would soon become cluttered. By grouping related files within a
directory, you can organize your files. You created the
cs108
directory to store all of the files for this lab
manual.
Since you are working on a lab exercise for this course, let's change the working directory to the appropriate directory.
Do this...
First, enter this command:
unix-%
cd courses
The cd
command is the change
directory command that changes the working
directory to the specified directory. Similar to the
mkdir
command, cd
will not display
anything if it works successfully (although you might notice a
change in your prompt). You will see an error message if something
fails.
Question #1.UNIX.05 What does the
pwd
command display now?
To be answered in Exercise
Questions/lab01.txt
.
Question #1.UNIX.06 How is the output of
pwd
different from before?
To be answered in Exercise
Questions/lab01.txt
.
Do this...
Now enter this command:
unix-%
cd cs108
Use the pwd
command to see if you're where you
think you should be.
So the cd
command allows you to navigate down a
directory hierarchy. What about going back up the hierarchy?
Do this...
First check out everything in your current directory by
entering this command:
unix-%
ls -a
The -a
switch tells ls
to list all of
the contents of a directory.
You will notice two odd items in this output: a period
.
and a double-period ..
. In the UNIX
file system, .
is another name for the working
directory (whatever directory you are in); and ..
is
another name for the parent directory of (i.e.,
the directory above) the working directory.
You created courses
within your home directory. The
cd courses
command took you from that directory "down"
into courses
. Once in that directory, .
refers to that same directory while ..
refers to the
directory that contains it (i.e., your home directory). Now that
you're in the cs108
directory, its .
entry refers to itself, and its ..
refers to the
courses
directory.
So now, to go back "up" a directory, you can enter this command:
unix-%
cd ..
Since ..
is always a synonym for the parent of the
working directory, regardless of any actual names, you can always
use this command in any directory.
Question #1.UNIX.07 What command do you now
need to enter to get back to your home directory?
To be answered in Exercise
Questions/lab01.txt
.
There's also a shortcut for changing directories back to your
home directory: use the cd
command without
any arguments.
Use pwd
to verify that you are currently in your
home directory.
console window, desktop environment, directory, flag, folder, hierarchical directory system, home directory, parent directory, prompt, root directory, switch, terminal window, working directory, xterm, X Windows System