Product information About the Author VirtualBook TM Information Purchase the Product FAQs Privacy Policy Copyright Contact Us Home Page

Online Campus

Model Answers

Exercise 1

Practical

Exercise 2A

  1. Practical
  2. Practical
  3. Yes - expresses everything that is typed in capital letters and intersperses the capital letters with / and other metacharacters.
  4. STTY -LCASE or STTY SANE -
  5. $

Exercise 2B

  1. An operating system is software that occupies a portion of the computers capacity i.e. hard disk and RAM. The operating system is loaded into memory at the boot-up of the machine. It controls the hardware and acts as an interface between the software, applications, the user and the hardware.
  2. If you are using the CD-ROM based course, then you are working on a Microsoft Windows based PC, and the Unix operating system that you are working with is a simulated environment, built to act like Unix.

Example 3e

In September 1752, our calendar changed from Julian to Gregorian. In order to correct the calendar two weeks had to be left off in this particular month and year.

Exercise 3A

  1. $ cal 12 1961
    This would be the syntax that is used. In this case the person was born in December 1961.
  2. $ cal 1902

Exercise 3B

  1. man
  2. practice in using on-line manuals
  3. and .. and .profile
    ls -la OR ls -a
  4. [ CTRL d ]exits mail because it is set to EOF (End Of File). Check this in the stty -a report.

Exercise 4A

  1. [ CTRL h ] OR Control h OR ^h
  2. Pressing [ CTRL g ] makes a bell sound or a beep. The shell will see the control character literally, and try to run it as a command
    ^G Not Found
  3. & 4. The right arrow key also performs a control character or function; therefore the system will attempt to interpret it as a command and will also issue an error message.

Exercise 4B

  1. $ touch file1 file2 file3 file4 OR
    $ touch file1
    $ touch file2
    $ touch file3
    $ touch file4
  2. Yes
    Yes
  3. $ ls -l
    Make a note of the creation time of the files called "file?"
  4. $ touch file3
  5. $ ls -l
    Yes
  6. 0 byte size file

Exercise 4C

1-3 Practical

Exercise 5A

Absolute pathname :
/gandalf/guests/guest1/courses/c3

Relative pathname :
guests/guest1/courses/c3 OR
./guests/guest2/courses/c3

Exercise 5B

  1. $ cd /tmp
  2. $ cd (short-cut)
    $ cd ../gandalf/guests/guest1 (relative)
    $ cd /gandalf/guests/guest1 (absolute)
    1. $ cd results/j1
    2. practical
    3. $ cd
      $ cd results/j1
      practical
    4. practical
      $ pwd
      $ cd ../../results/j1
    5. $ cd

Exercise 6

1.

    /dev/fd0primary floppy diskette (block device)
    /dev/fd0135ds18floppy diskette, density 135 and 18 tracks per inch (block device)
    /dev/fd096ds15floppy diskette, density 96 and 15 tracks per inch (block device)
    fd1secondary floppy diskette (block device)
    i6EOa Racal Interlan networking card (character device)
    lpline printer (character device)
    nullnull device for standard error if required (character device)
    rStp0SCSI tape device (character device)
    rfd0primary diskette (character device)
    rfd1secondary diskette (character device)
    tty01console terminal (character device)
  1. For the floppy diskettes and terminals, the major numbers are the same, but the minor numbers follow sequentially within the major numbers.

Page 104

Answer to question about [ CTRL ]d is that control d expresses the end of file [ eof ] in the stty -a report.

Exercise 7A

$ cat classical classic.bak
practical

Exercise 7B

$ ls -li / practical
Yes the content is the same.

Example 7e

$ ls -li

Exercise 7C

  1. They all manipulate files in some way by modifying directory entries and maybe even moving and copying datablocks.
  2. The I-node numbers are the same
  3. They are linked and therefore are the same physical program file.
  4. $ cd back to HOME directory
    $ mv courses/jan.bak . (to current directory.)

Example 7g

Answer should be no, classic will not be removed as well.

Exercise 7D

Practical

Exercise 7E

  1. $ more /etc/magic
  2. practical
  3. $ file *

Example 7h

  • Created two directories in your HOME directory, called mydir and dirname.
  • Executed a long listing in your directory to make sure that the command was successful and that the new directories exist.
  • Changed directory into one of the new directories, called mydir.
  • Performed a long listing with the - a option to see the hidden files. and ..
  • Changed directory back into your HOME directory using ..

Exercise 7F

  1. clear - clears the terminal screen display
  2. head - displays the first 10 lines of a file (10 by default)
  3. tail - displays the last 10 lines of a file (10 by default)
  4. last - Shows the login history on your system.
  5. tty - displays your terminal number.
    Practical
  6. uname - displays information about your system configuration, operating system version etc…
    practical
  7. compress and uncompress - as states compresses or uncompresses a file
    practical
  8. pack and unpack - packs or unpacks a file, should reflect that compress is more efficient.
  9. Finger - information about the users / processes on the system.
  10. Xtod - converts a file from Unix format to Dos format
    Dtox - converts a file from Dos to Unix format.

Exercise 7G

  1. $ rmdir courses
    Will not work, directory not empty
  2. $ rmdir mydir dirname
  3. $ mkdir /tmp/guest?
  4. $ rmdir /tmp/guest?

Exercise 7H

Practical using the on-line manuals.

Exercise 7I

  1. file1
    filesz
    file100
    file
    file2
    file.s
    file20
    file10
    files
    file.ext
  2. file1
    filesz
    file100
    file
    file2
    file.s
    file20
    file10
    files
    file.ext
  3. file1
    file2
    files
  4. none
  5. files
  6. files
  7. files
  8. apple
    classic

Exercise 8A

-rw-r-r-- filename

Exercise 8B

  1. $ touch perms
  2. $ pwd
    /gandalf/guests/guest1
  3. -rw-r-r-
  4. -rw-rw-rw-
    -rwxr-r-
    -rwxrwxrwx
  5. $ mkdir testperm
  6. drwxr-xr-x
  7. $ chmod 700 testperm
    OR
    $ chmod go-rx testperm
  8. $ chmod 600 testperm OR $ chmod u-x testperm
  9. drw-------
  10. yes
  11. $ cd testperm
  12. Cannot do a directory listing
  13. $ chmod 400 testperm OR $ chmod u-w testperm
  14. Yes

Exercise 8C

  1. $ chmod 375 testperm
    cd yes
    ls no
    touch no
    vi yes
  2. $ chmod 575 testperm
    cd yes
    ls yes
    touch no, cannot write in directory
    vi yes to read, but cannot save
    $ chmod 675 testperm
    cd no
    ls yes
    touch no
    vi yes, but can only read, cannot write or save changes or create a new file.
    $ chmod 375 testperm
    cd yes
    ls no
    touch yes
    vi yes - modify, save and create.
  3. Insert table 8.1a as the answer, but remove the file result column.

Exercise 9A

Practical

Exercise 9B - Modifying the .profile file

  1. $ cd
    $ pwd
    /gandalf/guests/guest1
  2. ls -la
  3. practical
  4. practical
  5. practical
  6. practical
  7. practical
  8. As you log in, all the requests or instructions that you have put into the .profile file will be performed or executed. This is a form or method of shell programming or scripting.

Exercise 9C

  1. Practical
  2. Practical
  3. Practical
  4. Practical
  5. Practical
  6. Practical and
    $ cat classic classic.bak the file display of both should be exactly the same.

Pg 179

ANS: The contents of classic.bak appears first, then the contents of the file called "classical". You have appended "classical" to the end of "classic.bak".
"classic.bak" has not been overwritten.

Exercise 9D

  1. practical
  2. practical
  3. practical

Example 9d

ANS: cp and copy commands. Using these commands is more efficient than using the redirection Example.

Exercise 9E

  • Yellow brass knob in the exact middle. The door opened on to a tube-shaped.
  • hall like tunnel: a very comfortable tunnel without smoke, with panelled
  • walls, and floors tiled and carpeted, provided with polished chairs and lots
  • It had a perfectly round door like porthole, painted green with a shiny
  • Yellow brass knob in the exact middle. The door opened on to a tube-shaped.

Exercise 9F

  1. No
    $ cat classical
  2. Practical
  3. Practical
  4. $ vi char (and add a list of alphabetical characters, one per line.
    A
    G
    S
    Y
    B
    D
    W
    J

    $ vi num (and enter a list of numbers, one per line)
    6
    2
    8
    1
    7
    3
    6
    4
    0
    6

    $ vi months (and enter a list of unordered months, one per line)
    august
    january
    february
    july
    december
    october
    November
    May
    July

  5. the screen
  6. no
  7. $ sort char > sortchar
    In the file called sortchar.
  8. $ sort t: -k 3n,3/etc/passwd > password OR
    $ sort t: +2n /etc/passwd > password

Advanced Lab

$ ls -l /bin | grep "^-[rwx-]*s"

Exercise 11A

  1. practical
  2. practical
  3. No
  4. Yes
  5. Just the shell process "sh"

Exercise 11B

  1. ps - reports on the process table
    w - reports on the processes and their status
    whodo - who is doing what on the process table

Example 12a

Because Unix treats a device file like an ordinary file, except that the device file will access a device driver and a device when it is accessed. Therefore if using a device file, the output will be backed up to a device file.

Exercise 12A

  1. tar backup
  2. Yes
  3. Yes
    Ascii
    Yes

Exercise 12B

  1. practical
  2. practical
    Find from the /gandalf/guests directory all the files and directory files and print a list of those files through a pipe to cpio. Where the list is taken from "standard Input" (now the list created from the find command), and all the files and directory files are backed up. Linking files wherever possible, retaining the modification time, creating directories as needed and printing the list of files being backed up to the Standard output which in this case is the terminal screen.

Exercise 13

  1. sar -q reports on the Run and Swap queue activity.
    sar -r reports on unused memory pages and disk blocks,
    freemem and freeswap
    sar -v reports on the status of the processes, I-nodes, files and file and record locking tables.
    sar -n reports on the effectiveness of the systems namei caches, the miss and hit ratios.
    sar -u report on processor utilisation, by users, system, input/output and idle time.

  2. Sar -q
    Processes stay in the run queue while waiting for a time-slice on the processor. The swap area will only be busy if there is not enough memory to handle the amount of activity.

    If your system is doing a lot of swapping then it is likely that you need to relook at your memory and buffer configuration.
    On an active healthy system, the run queue should be active, generally the bottleneck will be while the process is waiting on the sleep queue (part of the run queue) for a resource such as disk or memory, printer or terminal I/O etc… However once the resource is allocated to the process the time on the processor should be fairly efficient and quick.

    Sar -r
    Measuring free memory pages and disk blocks and free swap area will let you know how well allocated your memory buffers are. It will also let you know if you need to allocate more buffers if they are filling up continuously, or less buffers if they are never even partially used up.

    Sar -v
    Each table involved in this report is allocated a default number of slots and installation. I.e. Number of files allowed open at any one time.

    Generally it is found that the allocation is too much for the amount of files, or activity on the system.

    As these tables are active and loaded into memory, they are taking up memory space and could therefore be trimmed to free more memory for other work if needed.

    Sar -n

    Sar -u
    Reporting on processor utilisation is always interesting, in that most systems or processors are idle a great deal of the time.

    As discussed previously this is generally due to the hold up on the allocation of Input / Output and other resource allocation.

    The information will show the amount of processor time used with user processes, system processes, all other input / output process and the idle time of the system.

  3. Probably the most foolproof method of increasing your performance is to increase your memory resource by adding more memory.