SOLUTIONS TO REVIEW QUESTIONS


Section 1| Section 2| Section 3| Section 4| Section 5| Section 6| Section 7| Section 8| Section 9| Section 10| Section 11| Section 12| Section 13| Section 14| Section 15| Section 16

Section 1


  1. A Systems Administrator is responsible for allowing the users of a system to perform the work the need to complete as quickly, easily and efficiently as possible. The Systems Administrator will have to do anything that fulfills this responsibility.

  2. The answer to this is open to argument.
    A good Sys Admin should be

  3. Much the same as that of a Systems Administrator. Enable the programs that will run on a computer to complete as quickly, easily and efficiently as possible.

  4. Windows, Windows 95 (Chicago), OS/2, Windows NT, UNIX, and various legacy mini and main frame operating systems that still have a hold in certain niches.

  5. The kernel is the part of the operating system that must be in main memory at all times.

Section 2


  1. a) cd /usr/local
    b) ls /etc > listing
    c) wc -w /etc/passwd

  2. A link is a mechanism that enables a file or directory to be referred to by more than one name.

  3. Major responsibilities of a UNIX shell include

  4. a) Display the message the *s are out tonight'
    b) Creates a file count that contains the number of files in the current directory.
    c) Produce a directory listing of files and or directories that match the contents of the file file.list.

  5. a) Any filename (with at least one character and you can't have any less than 1, so every file).
    b) Any filename that doesn't start with a lowercase character, finishes with a lowercase character and has two characters inbetween (e.g. A34z).
    c) Any filename that finishes with a * character followed by any other character. The \ tells the shell to treat the * as a normal character.
    d) Any filename that starts with *?*?abc followed by any other characters. The ' ' tell the shell to treat the * and ? as normal characters.

Section 3


  1. 	#!/bin/sh
    
    	# make sure at least one parameter is passed in
    	if [ "$1" = "" ]
    	then
    	  echo ERROR: expect at least 2 numeric parameters
    	  exit 1
    	fi
    
    	total=0
    
    	for number in $*
    	do
    	  total=`expr $total + $number`
    	done
    
    	echo Total = $total
    

  2. 	#!/bin/sh
    
    	# make sure at least one parameter is passed in
    	if [ "$1" = "" ]
    	then
    	  echo ERROR: expect at least 2 numeric parameters
    	  exit 1
    	fi
    
    	total=0
    	count=0
    
    	for number in $*
    	do
    	  total=`expr $total + $number`
    	  count=`expr $count + 1`
    
    	  if [ $count -ne $# ]
    	  then
    	    echo -n "$number + "
    	  else
    	    echo -n "$number "
    	  fi
    	done
    
    	echo = $total
    

  3. Some version of the test command may not recognise the more exotic file types (named pipes, character device files etc.)
    
    	#!/bin/sh
    	if [ $# -eq 0 ]
    	then
    	  echo USAGE: $0 list_of_filenames
    	  echo $0 will return what type of files they are
    	  exit 1
    	fi
    	for filename in $*
    	do
    	  if [ -d $filename ]
    	  then
    	    type=directory
    	  elif [ -h $filename ]
    	  then
    	    type="symbolic link"
    	  elif [ -c $filename ]
    	  then
    	    type="character device file"
    	 elif [ -b $filename ]
    	  then
    	    type="block device file"
    	  elif [ -p $filename ]
    	  then
    	    type="named pipe"
    	  elif [ -f $filename ]
    	  then
    	    type="normal file"
    	  else
    	    type="something very unusual"
    	  fi
    
    	  echo $filename is a $type
    	done
    

Section 4


  1. #!/usr/local/bin/bash choice() # get users decision on what to do # include a bit of error recovery # users choice is returned in the variable response { response=0 while [ $response -lt 1 -o $response -gt 3 ] do echo echo Do you want to echo "1) copy $1 over the top of $2" echo "2) move existing $2 to $2.old and copy over $2" echo "3) cancel the operation" echo -n "Enter you choice (1,2,3) ==> " read response if [ $response -lt 1 -o $response -gt 3 ] then echo '**** ERROR: You must choose one of 1 2 or 3 ****' fi done } # # Main Program # if [ $# -lt 2 ] then echo Usage: $0 source destination echo $0 will copy the source file to destination file exit 1 fi if [ -r $2 ] then echo The file $2 already exists. choice $1 $2 case $response in 2) cp $2 $2.old;; 3) exit 1;; esac fi cp $1 $2
  2. #!/usr/local/bin/bash choice() # get users decision on what to do # include a bit of error recovery # users choice is returned in the variable response { response=0 while [ $response -lt 1 -o $response -gt 3 ] do echo echo Do you want to echo "1) copy $1 over the top of $2" echo "2) move existing $2 to $2.old and copy over $2" echo "3) cancel the operation" echo -n "Enter you choice (1,2,3) ==> " read response if [ $response -lt 1 -o $response -gt 3 ] then echo '**** ERROR: You must choose one of 1 2 or 3 ****' fi done } # # Main Program # if [ $# -lt 2 ] then echo Usage: $0 source destination echo $0 will copy the source file to destination file exit 1 fi # destination is the last parameter destination=`echo $* | cut -d' ' -f$#` # source is everything but the last parameter source_num=`expr $# - 1` source=`echo $* | cut -d' ' -f1,$source_num` if [ -r $destination ] then echo The file $destination already exists. # pass in source in " " so it is treated as one variable choice "$source" $destination case $response in 2) cp $destination $destination.old;; 3) exit 1;; esac fi cp $source $destination
  3. #!/usr/local/bin/bash space_used() # accept a username as 1st parameter # return amount of disk space used by the users home directory # in a variable usage { # home directory is the sixth field in /etc/passwd the_home=`grep ^$1: /etc/passwd | cut -d: -f6` # du uses a tab character to seperate out its fields # we're only interested in the first one usage=`du -s $the_home | cut -f1` } # # Main Program # while read username max_space do space_used $username if [ $usage -gt $max_space ] then echo $username has a limit of $max_space and has used $used >> offender fi done < disk.hog

  4. Section 5


    1. The type of question for which there is no correct solution. I wonder how many of you attempted it.

    2. Log book format is a personal decision. However it should be complete and easy to use and retrieve information from.

    Section 6


    1. This one's up to you.

    Section 7


    1. The solutions to this question can be taken straight out of Table

    2. Block: a disk block is the smallest unit of information that can be read from a disk drive. Typical sizes range from 512 bytes to 4Kb.
      Cylinder: a collection of disk tracks that are the same distance from the centre of the disk surface.
      File System: a) a collection of directory hierarchies.
      b) the code inside the kernel that performs various file and directory operations.
      i-node: The index node that is used to store and reference all information about a particular file. One i-node per file. Information contained includes permissions, size, number of links and the actual data of the file.
      Device File: The device file is an entry point into a particular device drive. It is characterised by a combination of major and minor device numbers.
      Major Device Number: Used by device files to point to the associated device driver.
      Minor Device Number: Used by device files to point to the entry point in the particular device driver.

    3. Two methods used to mount file systems are
      • the mount command, and
      • the file system configuration files either /etc/vfstab or /etc/fstab

    4. Decide on the number and size of partitions to be placed on the disk drive and then partition the drive.
      Create the appropriate file systems on each partition.
      Decide on the mount points for the various partitions.
      Mount the partitions either using the mount command or by modifying the file system configuration files.

    5. Differences between a hard link and a soft link
      • hard link is limited to within a partition, soft link isn't,
      • with a hard link both files point to the same i-node,
      • with a soft link the link has its own i-node that points to a file that contains the path of the file it's pointing.

    Section 8


    1. Another question for which there is no one correct solutions. A backup strategy must balance all the characteristics discussed in this section.

    2. Media: the physical medium onto which a backup is placed, tape, disk etc.
      Scheduler: the person or program that decides when to perform a backup and what to backup.
      Transport: the method by which the backup is transferred onto the media.

    3. See the discussion in the section.

    4. A question for you to complete.

    Section 9


    1. See Diagram 9.1.

    2. You might want to shut a UNIX computer down to
      • install a new device or kernel,
      • the machine has frozen due to some unrecoverable error,
      • as a simple maintenance process to force the operating system to perform various tasks it completes during booting.

    3. Four reasons why a UNIX computer may not reboot
      • a missing kernel (it isn't there or is in the wrong place),
      • disk drive error causing the root file system not to be found,
      • other hardware errors (cpu is burnt out etc),
      • the kernel is configured incorrectly,
      • the root file system is corrupt,
      • there is an error in one of the initialisation scripts

    4. Steps to be completed to shut a UNIX machine down properly include
      • warn the users that the machine is about to be shutdown (not strictly essential but recommended)
      • log out all users,
      • kill any background processes and daemons,
      • sync the disks making sure that all disk buffers have been flushed,
      • shut the machine off.

    5. On a Linux machine you can use the CTRL-ALT-DELETE key combination to reboot a system. If you examine the /etc/inittab file you will see an entry for when this happens. This entry tells init to run the shutdown command.

      When you do you use CTRL-ALT-DELETE the script /etc/rc.d/rc.0 is executed. This would imply that it is executed by shutdown. This means that somewhere in shutdown /etc/rc.d/rc.0 should appear.

      Try the command strings /sbin/shutdown Doing this the output reveals that there is no /etc/rc.d/rc.0.

      However there is call to halt. Perhaps halt executes the script. Try strings /sbin/halt.


    Section 10


    1. Terminal configuration files include
      • those files responsible for starting getty processes (/etc/inittab, /etc/ttys)
      • files responsible for setting the characteristics of the serial lines connecting the terminals and the computer (/etc/gettydefs)
      • terminal characteristic database files (/etc/termcap, terminfo)

    2. The solution to this question will depend on your system.

    3. Again this will depend on your system but it should resemble one of the systems outlined in the section.

    4. The login process on a terminal involves
      • /etc/init,
        The first process run on a UNIX system. It is init's responsibility to ensure that each terminal has a getty process running for it.
      • getty,
        Is responsible for setting up the characteristics of the line, displaying the login prompt, getting a username and executing the login process with the username as an argument.
      • login, and
        Is responsible for logging the user into the system, obtaining and validating the password, and executing the user's login shell.
      • a login shell.
        The user's entry in the /etc/passwd file lists the program to execute as the user's login shell. The shell will in turn execute the appropriate startup scripts.

    Section 11


    1. It will either be SysV or BSD based.

    2. lp and lpr are both print spoolers. They are responsible for placing user data destined for the printer into a spooling directory.

    3. lpd and lpsched are both print daemons. They are responsible for taking information to be printed from the spooling directory and handing it over to the printer.

    4. /etc/printcap is the BSD printer configuration file.

    Section 12


    1. gateway: A machine of some description (sometimes a computer) that acts as the translator between two different networks. It may sometimes perform some type of translation from one network protocol to another or it may simply pass packets from one network onto the other.
      port: A logical software connection through which TCP/IP protocols communicate.
      protocol: A specification about how two separate entities may communicate.
      daemon: A process designed to fulfill a particular type of request. It sleeps waiting for such a request when it arrives it wakes up performs some task and goes back to sleep.
      router: A machine of some description that forwards network packets to the right direction for them to reach their destination.
      bridge: A device used to connect to separate networks together (part of what a gateway may be).

    2. The telnetd daemon may not be running on hades or it may be refusing to take connections from the user's machine. The telnet program on the machine the users are coming from might be incorrect. The network between hades and the user's machine might be incorrectly set up in some way, packets may be getting lost while travelling to hades. The user might be using telnet incorrectly (typing in the wrong command or address for hades). The DNS on the user's machine may not be working correctly and so when the user types telnet hades the DNS is not translating it into an IP address, or perhaps it is translating it into the wrong IP address.

    3. Both TCP and UDP are transport protocols. They provide higher level protocols with services that enable the higher level protocols to send information from one host to another according to different characteristics.

    4. The machine name aldur may be resolved to its IP address by
      • a machine looking into its /etc/hosts file,
      • a machine checking its cache of hostnames and IP addresses,
      • a machine asking its nameserver for the translation (which then repeats these steps again ad nauseum until the host is resolved or it decides to give up)

    5. Each well-known Internet protocol will typically have a daemon listening on a specified port for incoming requests. The /etc/services file specifies which protocols belong to which ports and the /etc/inetd.conf specifies which daemons to run for which services.

    6. TCP/IP uses four layers
      • network access layer
        Responsible for the transformation of IP datagrams into a format that can be placed onto the hardware.
      • internet layer
        The Internet Protocol is the heart of this layer. Functions IP performs include defining the IP datagram and addressing scheme, and routing datagrams between remote hosts. It provides a well-defined protocol that from the higher layers (transport, application) will appear the same regardless of the hardware. This means that the transport protocols do not have to know about the different types of hardware since the Internet layer hides the hardware dependencies.
      • transport layer
        The transport layer is responsible for dividing (and putting back together) the user data into correct size datagrams for network transmission, and providing any additional transport controls such as error detection and reliable delivery.
      • application layer
        Protocols in the application layer add additional functionality by building on the transport layer.

    Section 13


    1. a) For this question you basically assume that everything is setup in the network etc. All that you must do is specify the location and contents of all the files needed by the r commands to operate.

      The two files necessay are

      • /etc/hosts.equiv
        Which specifies which machines are trusted.
      • .rhosts

      Located in each user's home directory and specifies accounts from specified machines which are considered equivalent to the local account even though they have different usernames.
      I'll be using david as my username.

      Gandalf


      /etc/hosts.equiv


      Should contain the list of machines and users on those machines which are considered trusted.

      bilbo david panea backup
      frodo root david backup arnold


      /.rhosts


      Contains all users who are allowed to remotely login as root. Probably would never have in a real system.

      bilbo david
      frodo david


      /home/tideyj/.rhosts


      The location of this file depends where Jim's home directory is. I'll assume the above. He wants to be able to come in from bilbo and frodo as the user backup.

      bilbo backup frodo backup


      /home/david/.rhosts


      bilbo root
      frodo root

      Any machine (e.g. gandalf) that wishes to be a trusted host of another (e.g. bilbo) i.e. the users want to be able to remote login. That machine (gandalf) must appear in the /etc/hosts.equiv file of the other (bilbo).

      Also if a account on the first machine has a different username than the account on the second machine. Then a .rhosts file must exist in the home directory of the account on the second machine.

      b) The main reason why this is not a good idea is security. The security mechanism associated with the Berkeley r commands is notoriously insecure.


    Section 14


    1. Issues that are important for system security
      • importance of data and service from machine,
      • size and ability of the user population,
      • whether or not he machine is networked,
      • how much effort is it deemed worthwhile to invest in security,
      • can the users handle the inconvienience,
      • the type of machine and operating system being used,
      • physical security threat.

    2. Methods which can improve the security of passwords include
      • shadow passwords,
      • proactive password programs,
      • password generators,
      • password aging,
      • password cracking,
      • user education, and
      • regular checks on the /etc/passwd file.

    3. Possible problems with internal security of a system include
      • incorrectly set file permissions,
      • unauthorised setuid or setgid programs,
      • a number of buggy system programs that supply security holes

    4. There are a number of things that can be done and are divided into two categories. Get a command-line on the machine and then get root access.
      • attempt to look over the shoulder of any user possible,
      • steal a few bags or rifle a few desks to obtain written down passwords,
      • try a number of known security holes that might get an account including sendmail bugs, bugs in some login programs and various other holes,
      • use a "network sniffer" program that catches and examines all packets being sent across a network,
      • change the permisions on various device files,
      • look for security holes in a number of system programs,
      • create a setuid root program when and if root access is achieved,
      • fiddle with the /etc/passwd file

    Section 15


    1. See Review Question 1.5

    2. The Systems Administrator has a number of responsibilities related to the kernel including
      • ensuring the system has a valid kernel to boot with,
      • configuring the kernel to represent the system's make up,
      • modifying the kernel code, and
      • compiling the kernel.

    3. Both the patch and diff commands are related to patch files. (see the section for more explanation).

    Section 16


    1. Refer to the description in the appropriate section.

    2. It will append the words this day is output of date command here to the file date.log. It will do this for every minute of every hour of the first day of January, June and December as long as that first day is a Sunday, Monday, Tuesday, Wednesday or a Thursday (assuming weekdays start with Sunday as 0).

    3. The BSD disk quota system works on a per user, per file system basis. Every individual user can have individual quotas on every different file system. The quotas and current disk usage of each user is kept in a file called quotas (or maybe quotas.user) in the root directory of every file system that has quotas installed. Quotas are checked by code within the kernel of the operating system.

    4. The syslog system provides a central place for the collection of status and error information about the system.

      David Jones (author)
      Chris Hanson (html 11/09/96)