

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  

![[Courses]](../icons/up.png)
![[Rich]](../icons/prev.png) ![[Home]](../icons/home.png) ![[Rich]](../icons/next.png)
![[Author]](../icons/author.png) |
Overview
All of the laboratory assignments for this course will be completed on
a UNIX operating system. In this lab, you will attain or review basic skills
for interacting with the UNIX operating system.
Acknowledgment
This lab was originally developed by Dr. Mark J. Sebern.
Preparation
You must have a valid user account and password on
concord.msoe.edu. If you are not sure about this,
contact CCSD (x7288) for assistance.
Assignment
For the purposes of this lab, it is assumed
that your account is configured to run the C shell (csh) or the Bourne Again shell (bash) as your
interactive shell (to determine which shell you are using type
echo $SHELL. Perform the following operations:
- Log into concord.msoe.edu. 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
(from list) command. Try the
"ls -l"
(option is an "el", not a "one") and
"ls -a
" variants as well.
- View the contents of the
/etc/xinetd.conf
file use the command:
cat /etc/xinetd.conf
(from concatenate). Try the command:
more /etc/xinetd.conf
(try hitting the space bar or the letter
q and see what they
do)
- Try the man (from
manual)
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 which means you can still use the command
line prompt.
- Make a copy of your text file with the cp
(from copy) command.
- Rename one of your text files with the mv
(from move) command.
- Delete an unneeded copy of your text file
with the rm
(from remove) command.
- Create a new subdirectory with the mkdir
(from make directory) command.
Copy your text file into the new subdirectory.
- Change your current directory to the
subdirectory with the cd
(from change directory) 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
(from present working directory)
command.
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 command recall:
If using csh
- 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.
If using bash
- Hit the up arrows to scroll back through the history of your
commands;
- 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, hit the arrow keys until you find it, and then
hit the enter key.
- To reissue the most recent command, hit the up arrow key, and then
press enter.
- Set a file to be read-only with the chmod
(from change mode) command.
Interpret the file permissions
displayed by the ls
-l command.
- Delete one or more directories with the rmdir
(from remove directory) 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 following command:
In csh
- printenv
or env
In bash
- set
or env
(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
email program.
- Log out of concord.msoe.edu with the logout or
exit
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
- 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 11pm, the day prior to week 2 lab)
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.
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.
|