Sample Key

 

for

 

UNIX Operating System

 

Level I

 

CIS126AA

 

 

 

C. Ray Esparza

Glendale Community College

 

Revised June 2006

 

Only For Open-Entry/Open-Exit UNIX Sections

 

 


Answers to REVIEW QUESTIONS UNIT I

 

1.         Where, when, and by whom was the UNIX operating system developed?

            The UNIX operating system was developed at Bell Laboratories in the late 1960s by Ken Thompson and Dennis Ritchie.

 

2.         When we say that UNIX can be "ported," what do we mean?

            We mean that it can be transferred easily to different computer systems.

 

3.         List and describe briefly 8 functions of an operating system:

 

a.         Input/Output:  it provides ways to store and retrieve data on disks or tapes, to interact with terminals, and produce paper output.

b.         Command Interpreter:  it reads commands typed at a terminal and translates them into instructions understood by the computer.

c.         Data Management:  provides a means of organizing data into logical groups called files.

d.         Program Development Tools:  provides assistance in writing and maintaining programs - compilers, debuggers, etc.

e.         Time-Sharing:  enables several people to use the computer at the same time (found only in larger operating systems, including UNIX).

f.          Security:  protects one user from another and the operating system from being damaged by all users; allows only authorized access to computer and data.

g.         Communication:  allows one computer to communicate with others and lets terminals transfer programs or data.

h.         Accounting:  keeps track of what each person has done on a computer in order to bill or account for resources used.

 

4.         Briefly describe the function of the UNIX scheduler:

            The UNIX scheduler enables more than one person to use the computer at a time (time-sharing).  It shares computer resources among the users.

 

5.         Briefly describe the process known as swapping.

            Swapping is the process of copying programs/data which are needed/not needed from disk to memory or from memory to disk, as necessary. 

 

6.         What is the difference between paging and swapping?

            Paging copies only parts of programs (and data) to and from memory as needed, while swapping technically copies the entire program or data file.  Paging is a refinement of swapping.


7.         What is the UNIX shell, and what is its function?

            The UNIX shell is the command interpreter.  It is a program which reads what the user types at a terminal, translates that into machine instructions, and performs those instructions.

 

8.         What is primary storage, and what is it used for?

            Primary storage is the computer's memory.  The computer can only execute programs or manipulate data that are in primary storage.

 

9.         What is secondary storage, and what is it used for?

            Secondary storage consists of a computer's disks.  (Note:  tape units are also considered secondary storage.)  Programs and data which are not needed immediately in primary storage are kept in secondary storage.

 

10.       What is the purpose of  creating file directories (often called, simply, directo­ries)?

            File directories help you to organize files in a structured fashion, so that all of your files are not jumbled up into one storage area.  They are like dividers in a notebook or recipe file, enabling you to organize files by category.

 

11.       What is your HOME directory?

            Your HOME directory is the directory into which you are placed when you log in to your UNIX system; it was assigned by the system administrator when your user ID was created on the system.

 

12.       What is a path name?

            A path name is the list of directories which must be traveled through in order to reach a particular file.  For example,  the following path is the list of directories which must be traversed in order to find a file located in the HOME directory of student trwalla:    /server/student/trwalla.  Here is the way in which the student directories on our UNIX system are arranged (their path):

 

root directory

represented by / when you do the pwd command

¯

/server directory

¯

¯

                           ¯                      ¯                                  ¯

                        /jjones /msmith             ...         /mtveriqu (student directories)


Assignment I-A

 

1.   Student must fill in password

 

2.   Listing I-A-1

     The following lines should be in file snow_white

 

Grumpy Gilliam

Bashful Baggins

Sneezy Snoqualmie

Dopey Dormer

Sleepy Slapdash

Doc Doberman

Happy Hooligan

Ima U. Student <--  student's name here

 

3.   Listing I-A-2

     The following lines should be in file sort.out

 

Bashful Baggins

Doc Doberman

Dopey Dormer

Grumpy Gilliam

Happy Hooligan

Ima U. Student <-- student's name will be in

Sleepy Slapdash         appropriate sorted order

Sneezy Snoqualmie

 

4.   Answers to wc questions must be filled in:

 

     a.   Answers to fill-in questions

     b.   will not be given

     c.   in this Example Book.

d.              Students must attempt these on their own!

e.              Try to use the format:  wc ______ filename

 

5.   Listing I-A-3

Only required file is shown;  others may be present:

 

     snow_white

 

6.   Answer to pwd question must be filled in:

 

     Answer not given in this Example Book.


Assignment I-B

 

1.   Answer to copy question must be filled in:

 

     Answer not given in this Example Book.

 

2.   Listing I-B-1

     Listing of file workers should have following lines:

 

Grumpy Gilliam

Bashful Baggins

Sneezy Snoqualmie

Dopey Dormer

Sleepy Slapdash

Doc Doberman

Happy Hooligan

Ima U. Student          <-- student's name

 

3.   Answer to rename question must be filled in:

 

     Answer not given in this Example Book.

 

4.   Listing I-B-2

Only required files are shown;  others may be present:

 

     employee_file 

     practice      

     snow_white

 

5.   Answer to mkdir question must be filled in:

 

     Answer not given in this Example Book.

 

6.   Answer to cd question must be filled in:

 

     Answer not given in this Example Book.

 

7.   Listing I-B-3

Only required files are shown;  others may be present:

 

     employee_file 

     snow_white

 

8.   Answer to pwd question must be filled in:

 

     Answer not given in this Example Book.


Assignment I-C

 

1.   Listing I-C-1 - snow_white must have these lines:

 

Winona Witch

Prince Pomeroy

Myra Mirror

Grumpy Gilliam

Sleepy Slapdash

Doc Doberman

Happy Hooligan

Ima U. Student     <-- student's own name

 

2.   Listing I-C-2 - employee_file must have these lines:

 

Winona Witch

Prince Pomeroy

Myra Mirror

Grumpy Gilliam

Sleepy Slapdash

Doc Doberman

Happy Hooligan

Ima U. Student

 

3.   Listing I-C-3

Only required files are shown;  others may be present:

 

     employee_file

     snow_white

 

4.   Listing I-C-4 - radio_days must have these lines:

 

Student, Ima       <--  student's own name here

Armstrong, Jack

Livingston, Mary

Trent, Helen

Gildersleeve, Throckmorton P.

 

5.   Answer about copy must be filled in:

 

     Answer not given in this Example Book.

 

6.   Answer about delete must be filled in:

 

     Answer not given in this Example Book.

 

7.   Listing I-C-5 - old_timers must be deleted; only required files are shown;  others may be present:

 

     employee_file

     radio_days

     snow_whit`e

Assignment II-A

 

1.   Answers about echo commands filled in:

 

     Answers not given in this Example Book.

 

2.   Listing II-A-1

Only required files are shown;  others may be present:

 

     assignments

     phone_book

     practice

     report1

     report2

     report3

     snow_white

 

3.   Answer about delete must be filled in:

 

     Answer not given in this Example Book.

 

4.   Listing II-A-2 - must show only ls.out2 ending in 0-9;

only required files are shown;  others may be present:

 

     assignments 

     phone_book  

     practice    

     snow_white

 

5.   Answer about copy must be filled in:

 

     Answer not given in this Example Book.

 

6.   Answer about copy must be filled in:

 

     Answer not given in this Example Book.

 

7.   Listing II-A-3 (assignments directory)

Only required files are shown;  others may be present:

 

     employee_file 

     phone_book    

     phoney_book

     radio_days    

     snow_white

 


Assignment II-A (continued)

 

8.   Answer about grep must be filled in:

 

     Answer not given in this Example Book.

 

9.   Answer about grep must be filled in:

 

     Answer not given in this Example Book.

 

10.  Listing II-A-4 - snow_white should have these lines:

 

Winona Witch

Prince Pomeroy

Myra Mirror

Doc Doberman

Grumpy Hooligan

Ima U. Student     <-- student's name

 

11.  Listing II-A-5 - employee_file should have these lines:

 

     Winona Witch

     Prince Pomeroy

     Myra Mirror

     Grumpy Gilliam

     Sleepy Slapdash

     Doc Doberman

     Happy Hooligan

     Ima U. Student     <-- student's name

 

12.  Listing II-A-6 - employee_new should have these lines:

 

     Winona Witch

     Grumpy Gilliam

     Sleepy Slapdash

     Doc Doberman

     Happy Hooligan

     Ima U. Student     <-- student's name

 

13.  Answer about tail must be filled in:

 

     Answer not given in this Example Book.

 

14.  Answer about head must be filled in:

 

     Answer not given in this Example Book.

 

15.  Answer about sdiff (or diff) must be filled in:

 

     Answer not given in this Example Book.


Assignment II-B

 

1.   Listing II-B-1 - radio_sorted should have these lines:

 

Armstrong, Jack

Gildersleeve, Throckmorton P.

Livingston, Mary

Student, Ima       <--  student's name will be in

Trent, Helen                 appropriate sorted order

 

 

 

2.   Listing II-B-2 - today should have a line like this;

 

     Fri Jan 21 14:09:00 MST 2006 <--  date/time when

                                      command was done

                                      will be shown

 

3.   Listing II-B-3 - employee_junk should have these lines:

 

Winona Witch

Prince Pomeroy

Myra Mirror

Grumpy Gilliam

Sleepy Slapdash

Doc Doberman

Happy Hooligan

Ima U. Student <--  student's name

Winona Witch

Grumpy Gilliam

Sleepy Slapdash

Doc Doberman

Happy Hooligan

Ima U. Student <--  student's name

Winona Witch

Prince Pomeroy

Myra Mirror

Doc Doberman

Grumpy Hooligan

Ima U. Student <--  student's name

 

4.   Answer to who-grep-sort command must be filled in:

 

     Answer not given in this Example Book.

 

5.   Answer to who-grep-sort-cut command must be filled in:

 

     Answer not given in this Example Book.


Assignment II-B (continued)

 

6.   Listing II-B-4:  Student's output will vary according to who was logged in when the command was done.  User IDs must be only those having tty, and they must be in sorted order.  The following is an example only:

 

     aefreun       (Note:  occasionally the student will be

     jtwilli       the only person logged in; this is

     pbmarsh       acceptable.)

     rmhowar

    


Assignment III-A

 

Listing III-A

 

Line printer listing of snow_white should show the following lines:

 

     Mrs. Winona Witch

     Myra Mirror

     Doc Doberman

     Gumpy Hooligan

     Ima U. Student VIP

 

 

Assignment III-B

 

Listing III-B

Note:  Paging of vi.doc will not be as shown.  Student's name must ap­pear in the first line.  Text which was to be changed or added has been underlined for your convenience.

 

Ima U. Student's vi Reference Document

 

 

Unless otherwise noted with <CR>, the following commands

do not require the user to press <Enter> or <Return>.

 

MODES:

 

        Command mode:   lets you use commands noted below

        Insert mode:    lets you enter text from the keyboard; use

                        <Esc> to exit text mode and reenter Command mode

 

CURSOR MOVEMENT COMMANDS:

 

         j               moves cursor down one line

         k               moves cursor up one line

         h               moves cursor left one space

         l               moves cursor right one space

         Ctrl-d          moves screen down 1/2 page

         Ctrl-u          moves screen up 1/2 page

         Ctrl-b          moves screen up a full page

         Ctrl-f          moves screen up a full page

         #               moves cursor to # number line of file

         0               moves cursor to beginning of current line

         $               moves cursor to end of current line

 

TEXT ENTERING COMMANDS:

 

        a               appends text AFTER cursor position

        i               inserts text BEFORE cursor position

        o               opens a new line below cursor

                        & enters insert mode

        O               opens a new line above cursor

                        & enters insert mode


Listing III-B (continued)

 

TEXT DELETION COMMANDS:

 

        x               deletes character under cursor

        dw              deletes from cursor to beginning of next word

        dd              deletes line where cursor is positioned

 

TEXT ALTERATION COMMANDS:

 

        r               replace character at cursor with next character

                        typed

        R               writes over old text (overstrike mode)

        cw              changes word to new text

        J               joins next line down to line with cursor

        u               undo last command

        U               undo all changes to line with cursor

        .               repeat the last command

 

SEARCH COMMANDS:

 

        /pattern        search for next occurrence of pattern

        ?pattern        search for previous occurrence of pattern

        n               repeat last search command given

 

TEXT MOVING COMMANDS:

 

        yy              yank a copy of a line and put in a buffer

        p               put last item yanked or deleted AFTER cursor

        P               put last item yanked or deleted BEFORE cursor

 

SUBSTITUTION COMMAND:

 

        :s/s1/s2/<CR>   change characters in string s1 to those in s2;

                        example:  :s/teh/the/  changes the string "teh"

                        to "the" in the current line"

 

SAVING TEXT and QUITTING EDITOR:

 

        :w<CR>          write the current text into the file

        :q<CR>          quit if no changes since last w

        ZZ              write and quit (same effect as next command)

        :wq<CR>         write and quit

        :w file2        write lines into a different file

 

SCREEN OPTIONS:

 

        :set showmode   make vi display INSERT or APPEND mode

        :set noshowmode turn off display of mode

        :set number     cause vi to precede each line with a number

        :set nonumber   turn off line numbering

 


Assignment III-C

 

Listing III-C-1 (listing of curr_year)

 

Listing should show the entire calendar for the current year (for example, 2006).  If your calendar is headed simply 06, then you have the calendar for 02 A.D. and not 2006!

 

Listing III-C-2 (listing of calendar month and year of student’s birth month and year)

 

   September 1987       EXAMPLE ONLY-Answers Vary!!

Su Mo Tu We Th Fr Sa

       1  2  3  4  5

 6  7  8  9 10 11 12    NOTE: day of birth MUST be

13 14 15 16 17 18 19         circled!

20 21 22 23 24 25 26

27 28 29 30

 

Answers to bc problems to be written on grading sheet:

 

     Answers not given in this Example Book.

 

Listing III-C-3

A listing of rm.doc should be attached; it will have a little over a page of information about the rm command.


Assignment III-D

 

Listing III-D-1  (Listing of dec.spell)

 

The following words will be listed in a single column:

 

Criator            disolve

Goverment          efffect

Hapiness           institued

Natrue             politicial

Safty              pursuiing

aHappiness         pusuit

coauses            shewn

consemt            theri

delcare            willl

 

Listing III-D-2 (Listing of declaration with spelling corrected [words in bold] and nroff commands)

 

.ll 5.5i

.pl 8.0i

When in the course of human events it becomes necessary for one

people to dissolve the political bands which have connected them with

another, and to assume among the powers of the earth, the separate

and equal station to which the Laws of Nature and of Nature's God

entitle them, a decent respect to the opinions of mankind requires

that they should declare the causes which impel them to the separation.

.sp

.ul

We hold these truths to be self-evident,

that all men are created equal,

that they are endowed by their Creator with certain unalienable Rights,

that among these are Life, Liberty and the pursuit of Happiness.

That to secure these rights, Governments are instituted among Men,

deriving their just powers from the consent of the governed.

.sp

That whenever any Form of Government becomes destructive of these ends,

it is the Right of the People to alter or to abolish it, and to

institute new Government, laying its foundation on such principles

and organizing its powers in such form, as to them shall seem most

likely to effect their Safety and Happiness.

.sp

.in .5i

Prudence, indeed, will dictate that Governments long established should

not be changed for light and transient causes; and accordingly all

experience hath shewn, that mankind are more disposed to suffer,

while evils are sufferable, than to right themselves by abolishing

the forms to which they are accustomed.

.sp

.in 0i

But when a long train of abuses and usurpations, pursuing invariably the

same Object, evinces a design to reduce them under absolute Despotism,

it is their right, it is their duty, to throw off such Government,

and to provide new Guards for their future security.


Assignment III-D (continued)

 

Listing III-D-3  (listing of declaration.out with correct nroff formatting)

NOTE: occassionally you may have to enter one blank line at the beginning of the file in order for it to print out correctly.

 

When in the course of human events it becomes necessary

for  one  people  to dissolve the political bands which

have connected them with another, and to  assume  among

the powers of the earth, the separate and equal station

to which the Laws of Nature and of Nature's God entitle

them,  a  decent respect to the opinions of mankind re-

quires that they should declare the causes which  impel

them to the separation.

 

We hold these truths to be self-evident, that  all  men

are created equal, that they are endowed by their Crea-

tor with certain unalienable Rights, that  among  these

are  Life,  Liberty and the pursuit of Happiness.  That

to secure  these  rights,  Governments  are  instituted

among  Men, deriving their just powers from the consent

of the governed.

 

That whenever any Form of Government  becomes  destruc-

tive  of  these  ends, it is the Right of the People to

alter or to abolish it, and to  institute  new  Govern-

ment,  laying its foundation on such principles and or-

ganizing its powers in such form, as to them shall seem

most likely to effect their Safety and Happiness.

 

     Prudence, indeed, will  dictate  that  Governments

     long  established  should not be changed for light

     and transient causes; and accordingly all  experi-

     ence hath shewn, that mankind are more disposed to

     suffer, while evils are sufferable, than to  right

     themselves  by  abolishing the forms to which they

     are accustomed.

 

But when a long train of abuses and usurpations, pursu-

ing  invariably  the  same  Object, evinces a design to

reduce them  under  absolute  Despotism,  it  is  their

right,  it is their duty, to throw off such Government,

and to provide new Guards for their future security.