NEW BRUNSWICK COMPUTING SERVICES
USER SERVICES GROUP

Getting Started With The UNIX Operating System
Exercise Answers

Answers to practice exercises

Practice 1 - Getting Started

After completing this practice, you will be able to log into a UNIX system and prepare your account for use in this tutorial.

  1. Find the ssh program on your computer (usually SSH or PuTTY) and start it. Exactly what you do depends upon the computer you have and what is installed on it. For an eden account session open a session to eden.rutgers.edu. For an rci account session open a session on rci.rutgers.edu.

  2. At the login: prompt, enter your NetID (your rci or eden username).

  3. At the password: prompt, enter your rci or eden password.

  4. The login screen often contains important system notices that should be read for important announcements. Please note the topics below.

    Messages vary with system and time. Usually something like
    ** Rutgers University Computing Services Instructional Computing
            Initiative **
                         ** For authorized use only **
    .
    All users are expected to comply with the "Acceptable Use Policy for
    Computing and Information Technology Resources" available at 
    http://rucs.rutgers.edu/acceptable-use.html.
    
    Email questions to help@eden or call NBCS Help Desk: (732) 445-HELP
    Email comments or problems with NBCS/RUCS services to
    nbcs_feedback@email.rutgers.edu EMERGENCIES: email operator@eden or
    call NBCS Operations: (732) 445-2293.
    
    Last login: Tue Apr 13 09:10:34 2005 from hammer.rutgers.
    Sun Microsystems Inc.   SunOS 5.9       Generic_112233-11
    
    Check out http://www.eden.rutgers.edu/webtools .
    Incoming telnet service to eden.rutgers.edu is no longer supported.
    Incoming sftp service is available via sftp.eden.rutgers.edu .
    gaim (Instant Message client) is now available
    	
    Take a few moments to review the announcements, if there are some you have not already read please go to the appropriate web page of the following:

    www.eden.rutgers.edu
    www.rci.rutgers.edu


    to read the details in the announcements.

  5. At the system prompt issue the command:

    ~koft/classprep

    to set up your account for this tutorial.

    You will be prompted to type the key you wish to use as your delete key. Please type either the "Backspace" or "Del" key, followed by the "Return" key. This command also will create files and directories (explained in a later chapter) for use in this tutorial.

  6. Logout and back in to have the standard environment for this class. If you have a menuing system when you login ask for help disabling them for this tutorial.

    On rci to restore your original settings after you are done with this class type:

    mv .login .login.class ; mv .login.OLD .login
    mv .cshrc .cshrc.class ; mv .cshrc.OLD .cshrc


    On eden to restore your original settings after you are done with this class type:

    mv .login.local .login.local.class
    mv .login.local.OLD .login.local
    mv .cshrc .cshrc.class ; mv .cshrc.OLD .cshrc


End of Practice 1 - Getting Started


Practice 2 - Using the man Command for Help

After completing this practice, you will be able to use "man" and "man -k" to find on-line help; you will also explore the use of some essential UNIX commands.

  1. Use the man command to get help for the "ls" command. What command did you type?

    man ls

  2. What ls option displays the size of files in blocks (other than the -l option, for long listing)?

    ls -s

  3. What do you do to change your login password?

    Go to http://www.rci.rutgers.edu/tools.php for rci, go to http://www.eden.rutgers.edu/tools.php for eden.

  4. Issue the command:

    man -k date | grep "(1)"

    to list user commands having to do with dates (for now consider the "| grep" to be a filter that will display the lines from the output of the "man -k date" to show only those with the string of characters (1) in them). Select one of the listed commands and use it to get the current date and time according to the computer. Which command did you use to get the system date and time?

    Date/time will vary.
    date


  5. Find commands that show who is logged onto the system you are on (hint see #4). What commands will do this?

    who, w or whodo

  6. What command will display a calendar for January, 2001 (hint see #4)? Use man to learn how to use that command, then use it to make sure, finally write the command here.

    cal 1 2001

  7. EXTRA: What command will display the calendar for the entire first year year of this millennium?

    cal 2001

End of Practice 2 - Using the man Command for Help


Practice 3 - Dealing with Files

After completing the practice, you will be able to view files and create empty files. In addition, you will create proper and improper file names, and observe the results. This practice will also generate error messages to familiarize you with what some error messages look like.

  1. Issue the command:

    cd

    to make sure you are in your home directory. Then issue the command:

    cd UNXclass

    to go to the UNXclass subdirectory.

  2. In the current directory, list all files in long format. What different types of files (plain files,directories, links or other) do you have?

    There should be directories, files, and links.

  3. The touch command can be used to create new, empty files. Use the following command to create a file named sky:

    touch sky

    What command will show you if you succeeded and the file sky now exists?

    ls or ls -l sky

  4. Attempt to create three empty files with the commands:

    touch baseball bat
    touch -bigfile-
    touch chili&beans


    What error messages occur and are any files created?

    "baseball" and "bat" are both created, not "baseball bat"; "-bigfile-" was seen as command line options, so touch failed. The "&" in "chili&beans" is interpreted by the shell -- it puts "touch chili" in the background. then tries to interpret "beans" as a command. Note: you could put single quotes around "baseball bat" and "chili&beans" to force touch to create them, but it is a bad idea.

    The above are examples of poor choices of file names.

  5. Issue the following command and briefly describe the results:

    cat big.file

    The file big.file is displayed on the screen.

  6. Now issue the following command and observe the results:

    more big.file

    What is the difference between the commands "cat" and "more"?

    More displays the file big.file one screen full at a time.

  7. When would you use "cat"? When would you use "more"?

    Cat would be used on small files or where you are interested in only the last screen full. More is for larger files. Cat may be used in other ways such as below.

  8. How many lines in big.file contain the character string "tcsh"? What command did you use?

    cat big.file | grep tcsh is one command you could use
    grep tcsh big.file is another.

  9. Copy the file "orig.1" to "copy.1". What is the command?

    cp orig.1 copy.1

  10. Check your quota status. What command did you use? Are you close to either your quota or your limit?

    quota -v
    Your mileage will vary

  11. What is your disk usage in the current directory and below? What is the command you used to check it?

    du
    Your mileage will vary

  12. Check and note the size of the file "big.file" (hint use "ls -s"). Reduce it with gzip and check the size of "bigfile.gz". Note below, roughly, how much reduction occured? Restore the file with gunzip.

    big.file.gz is roughly 1/3 the size of big.file

End of Practice 3 - Dealing with Files


Practice 4 - Learning the File System

After completing the practice, you will be able to use absolute and relative path names, examine directories, and navigate the file system.

  1. Return to your home directory. What command will do this?

    cd

  2. What is the absolute path to your home directory? What command displays this?

    Your results will vary.
    pwd

  3. Issue the command

    cd ~/UNXclass/NoWrite

    to go to the NoWrite subdirectory. From here, what are two ways to specify the file named "big.file" in the directory "UNXclass" (the parent of NoWrite) so that the command more can display that file?

    more ../big.file
    more ~/UNXclass/big.file
    are two possible ways (there are more).

  4. From within the NoWrite subdirectory delete the files "apple", "banana", and "cherry" that are in the UNXclass directory (the parent ofNoWrite). What is one way to do this?

    One way is    rm ../apple ../banana ../cherry

    rm ../apple
    rm ../banana
    rm ../cherry
        is another

  5. Use "cd" to go to the UNXclass directory (the parent of where you should now be). What command did you use?

    cd ..

  6. EXTRA: Can you think of another way to "cd" from "NoWrite" to "UNXclass"?

    cd ~/UNXclass

  7. Create three new directories in the UNXclass directory: "Letters", "Programs", and "Misc". What command(s) did you use?

    mkdir Letters Programs Misc

  8. Delete the directory "RemoveMe" and all its contents. What command(s) did you use?

    rm RemoveMe/* rmdir RemoveMe

  9. EXTRA: There is more than one way to do step the above. Can you name another way to do it?

    rm -r RemoveMe

End of Practice 4 - Learning the File System


Practice 5 - Printing files and restoring settings

In this practice you will practice printing files, checking print requests, and canceling print requests.

  1. Print the file "print.me.1" on the printer named "hill013lp1" without using "setenv" commands. What is this command?

    lpr -Phill013lp1 print.me.2

  2. Set your default printer to be "hill013lp1". What command did you use?

    setenv PRINTER hill013lp1

  3. Print the file "print.me.2" on the default printer. What command did you use?

    lpr print.me.2

  4. With separate "lpr" commands print the files "print.me.3" and "print.me.4" on the default printer. Display the default print queue, then cancel the print Job for "print.me.4". You may try this more than once if you don't get it canceled the first time. What are the commands you use to do this?
    Hint: You may want to write down the sequence of commands you will enter before you issue them as the above may happen quickly.

    lpr print.me.3
    lpr print.me.4
    lpq
    lprm job-#_for_print.me.4


  5. Optional: Restore the original startup settings to your account.

    On rci to restore your original settings after you are done with this class type:

    mv .login .login.class ; mv .login.OLD .login
    mv .cshrc .cshrc.class ; mv .cshrc.OLD .cshrc


    On eden to restore your original settings after you are done with this class type:

    mv .login.local .login.local.class
    mv .login.local.OLD .login.local
    mv .cshrc .cshrc.class ; mv .cshrc.OLD .cshrc


End of Practice 5 - Printing files and restoring settings

07/26/04

Rutgers University Computing Services

UNX 1 ES