|
Model Answers
Exercise 1
Practical
Exercise 2A
- Practical
- Practical
- Yes - expresses everything that is typed in capital letters and intersperses the capital letters with / and other metacharacters.
- STTY -LCASE or STTY SANE -
- $
Exercise 2B
- 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.
- 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
- $ cal 12 1961
This would be the syntax that is used. In this case the person was born in December 1961.
- $ cal 1902
Exercise 3B
- man
- practice in using on-line manuals
- and .. and .profile
ls -la OR ls -a
- [ CTRL d ]exits mail because it is set to EOF (End Of File). Check this in the stty -a report.
Exercise 4A
- [ CTRL h ] OR Control h OR ^h
- 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
- & 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
- $ touch file1 file2 file3 file4 OR
$ touch file1 $ touch file2 $ touch file3 $ touch file4
- Yes
Yes
- $ ls -l
Make a note of the creation time of the files called "file?"
- $ touch file3
- $ ls -l
Yes
- 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
- $ cd /tmp
- $ cd (short-cut)
$ cd ../gandalf/guests/guest1 (relative) $ cd /gandalf/guests/guest1 (absolute)
-
- $ cd results/j1
- practical
- $ cd
$ cd results/j1 practical
- practical
$ pwd $ cd ../../results/j1
- $ cd
Exercise 6
1.
| /dev/fd0 | primary floppy diskette (block device) |
| /dev/fd0135ds18 | floppy diskette, density 135 and 18 tracks per inch (block device) |
| /dev/fd096ds15 | floppy diskette, density 96 and 15 tracks per inch (block device) |
| fd1 | secondary floppy diskette (block device) |
| i6EO | a Racal Interlan networking card (character device) |
| lp | line printer (character device) |
| null | null device for standard error if required (character device) |
| rStp0 | SCSI tape device (character device) |
| rfd0 | primary diskette (character device) |
| rfd1 | secondary diskette (character device) |
| tty01 | console terminal (character device) |
- 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
- They all manipulate files in some way by modifying directory entries and maybe even moving and copying datablocks.
- The I-node numbers are the same
- They are linked and therefore are the same physical program file.
- $ 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
- $ more /etc/magic
- practical
- $ 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
- clear - clears the terminal screen display
- head - displays the first 10 lines of a file (10 by default)
- tail - displays the last 10 lines of a file (10 by default)
- last - Shows the login history on your system.
- tty - displays your terminal number.
Practical
- uname - displays information about your system configuration, operating system version etc…
practical
- compress and uncompress - as states compresses or uncompresses a file
practical
- pack and unpack - packs or unpacks a file, should reflect that compress is more efficient.
- Finger - information about the users / processes on the system.
- Xtod - converts a file from Unix format to Dos format
Dtox - converts a file from Dos to Unix format.
Exercise 7G
- $ rmdir courses
Will not work, directory not empty
- $ rmdir mydir dirname
- $ mkdir /tmp/guest?
- $ rmdir /tmp/guest?
Exercise 7H
Practical using the on-line manuals.
Exercise 7I
- file1
filesz file100 file file2 file.s file20 file10 files file.ext
- file1
filesz file100 file file2 file.s file20 file10 files file.ext
- file1
file2 files
- none
- files
- files
- files
- apple
classic
Exercise 8A
-rw-r-r-- filename
Exercise 8B
- $ touch perms
- $ pwd
/gandalf/guests/guest1
- -rw-r-r-
- -rw-rw-rw-
-rwxr-r- -rwxrwxrwx
- $ mkdir testperm
- drwxr-xr-x
- $ chmod 700 testperm
OR $ chmod go-rx testperm
- $ chmod 600 testperm OR $ chmod u-x testperm
- drw-------
- yes
- $ cd testperm
- Cannot do a directory listing
- $ chmod 400 testperm OR $ chmod u-w testperm
- Yes
Exercise 8C
- $ chmod 375 testperm
cd yes ls no touch no vi yes
- $ 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.
- Insert table 8.1a as the answer, but remove the file result column.
Exercise 9A
Practical
Exercise 9B - Modifying the .profile file
- $ cd
$ pwd /gandalf/guests/guest1
- ls -la
- practical
- practical
- practical
- practical
- practical
- 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
- Practical
- Practical
- Practical
- Practical
- Practical
- 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
- practical
- practical
- 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
- No
$ cat classical
- Practical
- Practical
- $ 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
- the screen
- no
- $ sort char > sortchar
In the file called sortchar.
- $ 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
- practical
- practical
- No
- Yes
- Just the shell process "sh"
Exercise 11B
- 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
- tar backup
- Yes
- Yes
Ascii Yes
Exercise 12B
- practical
- 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
- 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.
- 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.
- Probably the most foolproof method of increasing your performance is to increase your memory resource by adding more memory.
|