[MSOE Homepage]

Dr. Taylor's MSOE Homepage

Unix is a Four
Letter Word

My Photo Album

My Personal Homepage

CS-321 Main page

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:

  1. 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.
  2. If you have not previously changed your default password, you should do it now, using the yppasswd command. Its operation is self-explanatory.
  3. 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.
  4. 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".
  5. Try the man command to access on-line documentation. For example, type "man ls" to get information on the ls command.
  6. 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.
  7. 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.
  8. Make a copy of your text file with the cp command.
  9. Rename one of your text files with the mv command.
  10. Delete an unneeded copy of your text file with the rm command.
  11. Create a new subdirectory with the mkdir command. Copy your text file into the new subdirectory.
  12. Change your current directory to the subdirectory with the cd command.
  13. Get a directory listing of the parent directory with the " ls -l .." command, where ".." refers to the parent of the current directory.
  14. Display your current working directory with the pwd command.
  15. 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 ("\").
  16. Try using wildcards ("*" and possibly "?") with commands (e.g., " ls *.txt").
  17. Try using C-shell command recall:
    1. 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.
    2. Issue a few different commands, then type "history ". You should see a list of recent commands, each prefixed by a number.
    3. To reissue a command type the "! " (exclamation point or "bang") character, followed by the command’s number (no space).
    4. To reissue the most recent command, type " !!". More complex editing and recall operations are possible; consult a reference or the csh man page.
  18. Set a file to be read-only with the chmod command. Interpret the file permissions displayed by the " ls -l" command.
  19. 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.
  20. Experiment with redirecting command output (e.g., "ls -l >file1"). Try ">> " instead of " >" with an existing text file as the output.
  21. See whether upper-case versions of any of these commands work as well as the lower-case versions.
  22. Use the who command to see users logged into the system.
  23. Pipe the output of the who command to the sort command (e.g., " who | sort >whofile ").
  24. Search for your login name in whofile (see prior step), using the grep command.
  25. Compare two text files with the diff command.
  26. Count lines, words, and characters in a file with the wc command.
  27. Display your current environment variables with the printenv or env commands. (More on environment variables later.)
  28. Display information on yourself or another user with the finger command.
  29. If you wish, experiment with sending and receiving mail using the pine mail program.
  30. 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.

  1. find
  2. du, df
  3. file
  4. head, tail
  5. whereis
  6. time
  7. lp, lpr, lpstat, cancel (check your aliases with "alias")
  8. tr
  9. grep
  10. vi (On some DEC keyboards, you must type "ctrl-[" to get the escape character.)
  11. compress, uncompress
  12. tar (use with container or "archive" files only, not tapes)
  13. 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.