|
|
 |
CS-321 Lab 1: Introduction to the Unix Programming Environment
Fall Quarter 1999
Electrical Engineering and Computer Science Department
Dr. Christopher C. Taylor
S-331, 277-7339

www.msoe.edu/~taylor/
Acknowledgment
This lab was originally developed by Dr. Mark J. Sebern.
Overview
The purpose of this lab is to attain or review
basic skills for interacting with the Unix operating system.
Preparation
You must have a valid user account and password
on TORRES. If you are not sure about this, contact CCSD
for assistance.
Lab activity
For the purposes of this lab, it is assumed
that your account is configured to run the C shell (csh) as your
interactive shell. Perform the following operations:
- Log into TORRES. In most labs, the
best way to do this is probably via the eXcursion X
server software. If you are not familiar with this
software, ask the instructor or a fellow student for
assistance.
- If you have not previously changed your
default password, you should do it now, using the yppasswd
command. Its operation is self-explanatory.
- List your current directory with the
ls command. Try the "
ls -l"
(option is an "el", not a "one") and
"ls -a
" variants as well.
- Print out the contents of your
.login file, using the command "cat .login
". Try doing the same thing with "more .login
"; in this case, you may need to press the
space bar to view subsequent "pages".
- Try the man
command to access on-line documentation. For example,
type "man ls"
to get information on the ls
command.
- Create a small text file with the
pico editor (e.g., "
pico text.txt
"). This editor (part of the Pine mail
system) displays control key combinations, making simple
operations relatively straightforward.
- Try editing files with nedit
(a Motif-based editor). The normal way to invoke it is with
the command line "nedit &" or "nedit file.c
&"; the ampersand at the end causes the program
to run in the background without locking up the terminal
window used to start it.
- Make a copy of your text file with the cp
command.
- Rename one of your text files with the mv
command.
- Delete an unneeded copy of your text file
with the rm
command.
- Create a new subdirectory with the mkdir
command. Copy your text file into the new
subdirectory.
- Change your current directory to the
subdirectory with the cd
command.
- Get a directory listing of the parent
directory with the "
ls -l .."
command, where ".." refers
to the parent of the current directory.
- Display your current working directory
with the pwd
command.
- Create a number of hierarchically related
directories and navigate through them using a combination
of absolute pathnames (starting with "/") and
relative pathnames. Note that UNIX pathnames are similar
to MS-DOS, but use the forward slash ("/")
instead of the backslash ("\").
- Try using wildcards ("*"
and possibly "?") with
commands (e.g., "
ls *.txt").
- Try using C-shell command recall:
- Type the shell command "set history=10
"; The "10" is arbitrary,
and specifies the number of past commands you
want to keep. Later, you will probably want to
add this command to your
.cshrc
file, so it will be executed whenever a
copy of the C shell is started.
- Issue a few different commands,
then type "history
". You should see a list of recent
commands, each prefixed by a number.
- To reissue a command type the
"!
" (exclamation point or
"bang") character, followed by the
commands number (no space).
- To reissue the most recent
command, type "
!!".
More complex editing and recall operations are
possible; consult a reference or the csh
man page.
- Set a file to be read-only with the chmod
command. Interpret the file permissions
displayed by the "
ls -l"
command.
- Delete one or more directories with the rmdir
command. See what happens if the directory is
not empty. Experiment (carefully!) with the "rm -r
" command to delete a directory and its
content.
- Experiment with redirecting command output
(e.g., "ls
-l >file1"). Try ">>
" instead of "
>"
with an existing text file as the output.
- See whether upper-case versions of any of
these commands work as well as the lower-case versions.
- Use the who
command to see users logged into the system.
- Pipe the output of the who
command to the sort
command (e.g., "
who | sort >whofile ").
- Search for your login name in whofile
(see prior step), using the grep
command.
- Compare two text files with the diff
command.
- Count lines, words, and characters in a
file with the wc
command.
- Display your current environment variables
with the printenv
or env
commands. (More on environment variables
later.)
- Display information on yourself or another
user with the finger
command.
- If you wish, experiment with sending and
receiving mail using the pine
mail program.
- Log out of TORRES with the logout
command (or perhaps the control-D character).
Next, if you have time, try out each of the
following UNIX utilities and commands. For documentation, see the
on-line manual (man)
pages or any UNIX reference text.
If all else fails, ask the
instructor.
- find
- du, df
- file
- head, tail
- whereis
- time
- lp, lpr, lpstat, cancel (check your
aliases with "alias")
- tr
- grep
- vi (On some DEC keyboards, you must type
"ctrl-[" to get the escape character.)
- compress, uncompress
- tar (use with container or
"archive" files only, not tapes)
- uuencode, uudecode
You may wish to take a look at
Unix is a Four Letter
Word, a Unix manual that I wrote as a summer intern.
Next, think about common operations you perform
in other environments (e.g., MS-DOS, windows), and try to find ways to
accomplish these functions on UNIX. Ask for assistance as needed.
(Software development, including compiling and linking, will be
covered in more detail in a later lab.)
Lab report (due 4:30pm September 15, 1999)
You should submit a brief report detailing any problems you encountered,
operations that need to be clarified, or things you could not figure out
how to do (or did not have time to complete).
As with any report you submit, correct spelling and grammar are
required. In addition, your report should be submitted electronically
following the Electronic Submission
Guidelines. (You may wish to consult the
sample report before submitting your
report.) Be sure to keep copies of all your files, in case something
gets lost. It may be wise to keep a diskette backup as well.
If you have any questions, consult the instructor.
Copyright 1999.
|