Lab 1

Up Next

horizontal rule

Home
Lab 1
Lab 2
Lab 3
Lab 4
Lab 5
Lab 6
Lab 7
Lab 8
Lab 9
Lab 10
Lab 11
Lab 12
Lab 13
Lab 14
Lab 15
Lab 16
Lab 17
Lab 18
Lab 19
Lab 20

 

Lab 1

(Chapter 0)

 

 


 

Learning Objectives

  1. To practice identifying parts of a UNIX command.
  2. To identify and describe your method of connecting to a UNIX system.
  3. To practice using file maintenance commands.
  4. To build and manipulate simple file structures in your home directory.
  5. To further examine man pages for file maintenance commands.
  6. To practice using various utility commands for the beginner.

 

Lab Work

 

  1. In the exercises below, what you type-in at the UNIX command line is shown in Courier font. In the following commands, identify the parts of the single UNIX command presented by printing the letters C (for Command), O (for Option), OA (for Option Argument), and CA (for Command Argument) directly over the command line, such as-

 

                   C          OOA           O   OA              CA                               Answer

Sample - $ lpr  –Pspr   –n  3   proposal.ps                Command line

 

 

1.   $  ls -la convert.txt

 

2.   $  more convert.txt

 

3.   $  pwd

 

4.   $  cat file1 file2 file3

 

5.   $  rm  -r  temp

 

6.   $  ping –c 3 cse.ogi.edu

 

7.   $  telnet cs.berkeley.edu 13

 

8.   $  cc -o short short.c -lbaked

 

9.   $  chmod u+rw file1.c

 

10. $  uname –n

 

  1. Log on to your UNIX system. Make an exact list of exactly what steps you employ when logging-into and out of your UNIX system, and in the list, describe each step briefly in a sentence or two. Then, compare this list and its descriptions to the general connection categories and methods in Section 0.3 of the textbook.

Your method of logging-in and out is most similar to which general connection category, LAN(Intranet), Internet, or Stand-Alone? Be specific in your answer about why and at what point(s) or stage your method is most similar. Also carefully list the differences between your connection method and the general connection categories.

If your answer from above is LAN(Intranet), which method is it most similar to, i.e. UNIX Terminal, PuTTY, or Telnet client which are shown in Sections 0.3.1, 0.3.2, and 0.3.3 of the textbook? Be specific in your answer about why and at what point(s) or stage your method is most similar. Also carefully list the differences, and at what point(s) or stage these differences exist, between your method and the methods shown in the textbook.

If your method of connection is completely different from anything shown in Section 0.3 of the textbook, try to give a descriptive name to your method. For example, we regularly connect to a UNIX system via HyperTerminal on a Windows XP computer, using a dial-up connection through a phone modem. It is not an Internet, or Stand-Alone category connection, but is really an offshoot of the LAN connection category. We could call this a Dial-Up Connection. Add your descriptive name as a title to your list from above.

 

  1. After you have successfully logged-in using your method from above, in the console or terminal window, type the following UNIX commands on the command line. Note and write down the results (The command line prompt is shown as a $, which may be different on your system):

a.   $ ls

b.   $ pwd

c.   $ xy

d.   $ cd ..

e.   $ pwd

f.    $ cd

g.   $ pwd

h.   $ cd /usr/local

i.    $ ls

j.    $ cd

 

  1. In preparation for the following steps, create two (2) text files in your home directory on your UNIX system named 1st and 2nd, by using the cat command example shown on page 13 of Section 0.4.1 of the textbook. You may type whatever text you want into these files, as long as it consists of printable characters that can be viewed on the UNIX command line. Also, after executing the following steps for each figure, if you delete files 1st and 2nd by mistake, then recreate them before you go on to the next figure.

Using the figures found below, and the file maintenance commands covered in Section 0.4 of the textbook, create a directory and file structure under your home directory on your UNIX system exactly as shown in each figure. A directory is represented in the figures as a rectangle, and a file is represented as a circle. Then, write down a list of exactly what commands you used in sequence to create the structure for each figure. The directories and files that already exist in your home directory before you begin are irrelevant for our purposes in these exercises. In the event that directories that already exist in your home directory before you start any exercise have the same exact names as any of those shown in the figures below, then simply make up your own names for what is shown in the figures, and create the structure using your own names. Hint: You can always use the pwd and ls commands at any point in the construction process to verify the fidelity of your structure.

Once you have finished building each structure, use the appropriate file maintenance commands from Section 0.4 of the textbook to completely undo what you have done above. Then write down a list of exactly what commands you used in sequence to undo the structure for each figure. "Undo" means delete the directories and files created for that figure, except for files 1st and 2nd. The files 1st and 2nd must remain in your home directory after you have undone the directory and file structure for any particular figure, so that you can use them to create the structure for the next figure.

 

 

 


 

 

 

 


 

 

  1. Use the man command on your UNIX system to construct a table of one sentence long descriptions for all ten (10) file maintenance commands found in Section 0.4 of the textbook. Put the Description part of the manual page that you see displayed on-screen into your own words in one-sentence format, being careful to include the most important aspect(s) of the command as you find them stated in the description.
  2. After making the list of command descriptions from above, what changes would you make in the ways you constructed the file structures for the figures in the previous section?

 

In preparation for the next exercises, view and make notes about the use of the lpr or lp commands on your UNIX system by viewing the man pages for those commands. Note that if your UNIX system has another print command available that your instructor recommends you use, then substitute this command, and its syntax and procedures, for the lpr or lp commands in the exercises below. For example, our UNIX system has a macro command named "print", which allows you to do the same thing as the lpr or lp commands.

 

  1. Use the lpr or lp commands on your UNIX system to print the text files 1st and 2nd that you created with the cat command above.
  2. Use the cat command to create a new text file named "letter", and print this new file using the lpr or lp commands at your UNIX system line printer.
  3. Create a text file named "manual_mkdir" of the contents of the man page for the command mkdir by typing the following command on the UNIX command line: man mkdir > manual_mkdir. This command is similar to what is shown in the textbook, and is an example of output redirection; the > character redirects the output of the manual page from the man command to a file, which you have specified as manual_mkdir. Print this file to your UNIX system line printer using the lpr or lp command.
  4. From within an e-mail system you are able to use on your UNIX system, either print an e-mail message using the facilities of the e-mail system, or save an e-mail message to a file and print it to the lineprinter using the lpr or lp commands.
  5. Depending upon the default shell that you run when you login to your UNIX system, create the command aliases found in Table 0.2 on page 31 of the textbook, for your use whenever you login.
  6. Log out.

 

horizontal rule

Back to CS140U Homepage
This page was last modified September 26, 2004
wmorales@pcc.edu