CS321 -- Lab 1: Introduction to Unix



->Courses
->CS321
-->Presentation
->Lab 1
-->Lab 2
-->Lab 3
-->Lab 4
-->Lab 5
-->Lab 6
-->Lab 7
-->Lab 8
->Electronic Submission
->Old Exams
->C++ Examples
->Unix Help
->Software
->Tentative Schedule
->Course Policies

[Courses]
[Rich][Home][Rich]
[Author]

Fall Quarter 2001

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:

  1. 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.
  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 (from list) command. Try the "ls -l" (option is an "el", not a "one") and "ls -a " variants as well.
  4. 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)
  5. Try the man (from manual) 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 which means you can still use the command line prompt.
  8. Make a copy of your text file with the cp (from copy) command.
  9. Rename one of your text files with the mv (from move) command.
  10. Delete an unneeded copy of your text file with the rm (from remove) command.
  11. Create a new subdirectory with the mkdir (from make directory) command. Copy your text file into the new subdirectory.
  12. Change your current directory to the subdirectory with the cd (from change directory) 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 (from present working directory) command.
  15. command.
  16. 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 ("\").
  17. Try using wildcards ("*" and possibly "?") with commands (e.g., "ls *.txt").
  18. Try using command recall:
    If using csh
    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.
    If using bash
    1. Hit the up arrows to scroll back through the history of your commands;
    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, hit the arrow keys until you find it, and then hit the enter key.
    4. To reissue the most recent command, hit the up arrow key, and then press enter.
  19. Set a file to be read-only with the chmod (from change mode) command. Interpret the file permissions displayed by the ls -l command.
  20. 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.
  21. Experiment with redirecting command output (e.g., ls -l >file1). Try ">> " instead of " >" with an existing text file as the output.
  22. See whether upper-case versions of any of these commands work as well as the lower-case versions.
  23. Use the who command to see users logged into the system.
  24. Pipe the output of the who command to the sort command (e.g., who | sort >whofile).
  25. Search for your login name in whofile (see prior step), using the grep command.
  26. Compare two text files with the diff command.
  27. Count lines, words, and characters in a file with the wc command.
  28. Display your current environment variables with the following command:
    In csh
    printenv or env
    In bash
    set or env
    (More on environment variables later.)
  29. Display information on yourself or another user with the finger command.
  30. If you wish, experiment with sending and receiving mail using the pine email program.
  31. 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.

  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
  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 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.

© 1998-2001 Dr. Christopher C. Taylor Office: CC-27C Phone: 277-7339 Last Updated: September 18, 2001
I am responsible for all content posted on these pages; MSOE is welcome to share these opinions but may not want to.