System Administration



  1. Common UNIX Directories.
    In 1993, the Linux community formed a project to provide a standardized filesystem layout.
    This has evolved into the Filesystem Hierarchy Standard or FHS.
    1. Data Types
      1. Data Sharing. - the scope of data in a networked environment.
        1. Sharable - Can be used by multiple host systems on a network
        2. Non-sharable - Unique to a single host such as a passwd file.
      2. Data modification
        How the data changes.
        1. Variable - Changed by natural, frequent processes.
        2. Static - Left alone for the most part, such as configuration files
      3. FHS Data Types
        . Sharable Non-sharable
        Static /usr
        /usr/local
        /etc
        /boot
        Variable /var/mail
        /home
        /var/log
        /proc

    2. The filesystem
      1. / (root) The root directory is present in all UNIX system file structures. It is the ancestor of all files in the filesystem.
      2. /bin Public commands are stored in this directory.
      3. /lib System libraries such as the standard C library.
      4. /etc Administrative and management commands and area. System configuaration files are kept here.
      5. /mnt Mount points for temporary partitions for cdrom etc.
      6. /dev All Unix devices are treated as files. This directory list the special file associated with every device on the system. Devices fall into two categories character serial and block structure.
        1. Character serial devices - Those devices from which characters can be read or written only in a serial fashion such as terminals, printers and magnetic tapes. The UNIX system attempts to make serial devices look like ordinary files to the users.
        2. Blocked structured devices - These devices used in the file system, allow the movement of the read/write heads. These are available to the users through file input/output requests.
        3. Viewing the devices. An ls -l of /dev will show a c or b in the first position to denote either character or blocked device.
          brw-r-----  1 root       7,  80 Oct 13  1990 sd10a
          brw-r-----  1 root       7,  81 Oct 13  1990 sd10b
          brw-r-----  1 root       7,  82 Oct 13  1990 sd10c
          crw-rw-rw-  1 root      20,  38 Oct 13  1990 ttyr6
          crw-rw-rw-  1 root      20,  39 Oct 13  1990 ttyr7
          crw-rw-rw-  1 root      20,  40 Oct 13  1990 ttyr8
          
      7. /home Home directories for system users.
      8. /opt Intended for software other than that packaged with the operating system.
      9. /tmp Temporary storage. The contents are deleted upon every system boot.
      10. /usr A hierarchy od executable programs.
        1. /usr/X11R6 - X windows
        2. /usr/bin - primary location for user commands.
        3. /usr/games - older text games
        4. /usr/include - Header files for C and C++.
        5. /usr/lib -Shared libraries, such as perl support.
        6. /usr/local - Intended for use by the sysadmin.
        7. /usr/sbin - Primary location for sysadmin commands.
        8. /usr/share - Static daa such as GNU info system files.
        9. /usr/src - Linux source code
        10. Binaries
          . User Commands Sysadmin Commands
          Vendor supplied
          essential
          (root filesystem)
          /bin /sbin
          Vendor Supplied
          no-essential
          (/usr)
          /usr/bin /usr/sbin
          Locally suppied
          non essential
          /usr/local/bin /usr/local/sbin
      11. /var Data that varies over time such as logs, mail and spools.
        1. /var/cache - temporary storage intermediate data
        2. /var/account - accounting data
        3. /var/crash - crash dumps for OS.
        4. /var/lock - lock files.
        5. /var/log - logs
        6. /var/mail
        7. /var/spool



  2. Disk Device names (Linux only).

    1. IDE (Integrated DEvice Electronics). drives.
      1. /dev/hda - primary master IDE (often the hard disk).
      2. /dev/hdb - Primary slave IDE
      3. /dev/hdc - Secondary master IDE (often a CD-rom)
      4. /dev/hdd - secondary slave IDE

    2. SCSI (Small computer System interface) drives.
      1. /dev/sda - First SCSI drive
      2. /dev/sdb - Second SCSI drive and so on.

    3. Disk Partitions

      Each disk may contain between 1 and 16 partitons.Each partition is assigned an integer number that is appended to the device name. For example the first partition on IDE disk /dev/hda is /dev/hda1. The three types of partitions are:

      1. Primary partitions. Contains a file system. At least one primary must exist.Up to four can exist on single physicl disk. If all four primary patitions exists they are:
        • /dev/hda1
        • /dev/hda2
        • /dev/hda3
        • /dev/hda4
        One of these primary partitions may be marked active in which case it can be selected for booting.

      2. Extended Partitions. A variant of a primary partition but it does not contain a filesystem. Instead it contains logical partitions. Only one extended partition may exist on a single physical disk. It takes one of the four primary position spots. On a disk with one primary and the sole extended partition are numbered:
        • /dev/hda1 (primary)
        • /dev/hda2 (extended).

      3. Logical Partitions. These exists within an extended partition. 1 to 12 logical partitions may be created. Logical partitions are numbered 5 to 16. The partitions ona disk with one primary, one extended and four logical partitions would be numbered as follows:
        • /dev/hda1 (primary)
        • /dev/hda2 (extended)
        • /dev/hda5 (logical)
        • /dev/hda6 (logical)
        • /dev/hda7 (logical)
        • /dev/hda8 (logical)

      4. Example partitioning scheme.
        On an IDE based system with two physical disks on the primary IDE controller the disk layout might look like:
        partitionTypeMounted FilesystemSize
        /dev/hda1Primary/300 MB
        /dev/hda2Extended--
        /dev/hda5Logical/boot300 MB
        /dev/hda6Logical/opt300 MB
        /dev/hda7Logical/tmp300 MB
        /dev/hda8Logical/usr600 MB
        /dev/hda9Logical/var300 MB
        /dev/hda10Logical(/swap partition)128 MB
        /dev/hdb1Primary/home6 GB



    4. The physical file system.

      1. blocks
        Disks are divided into 1024 bytes called blocks.
      2. block zero
        Block zero is the boot block.
      3. super block Block one is the super block which contains the size of the disk, the size of the i-list and the size of the data blocks.
      4. i-list
        The i-list contains the i-nodes. The i-node contains the file's size, owner, group, permission bits, and the disk addresses.
      5. Controlling the filesystem
        The UNIX system administrator can control the file system through the following commands.
        • /etc/mkfs - make a file system.
        • /etc/mount - mount a file system.
        • /etc/umount - unmount a file system.
        • df - report free space on file systems.
          $ df
          Filesystem    Total KB    free %used   iused %iused Mounted on
          /dev/hd4         49152   33776   31%     831     6% /
          /dev/hd9var      16384    9900   39%     179     4% /var
          /dev/hd2       1515520  664744   56%   24338     6% /usr
          /dev/hd3        327680  311576    4%      67     0% /tmp
          /dev/hd1         81920   49492   39%     584     2% /home
          /dev/lv01       327680  175616   46%    2448     2% /public
          
        • du - display number of disk blocks per directory of file.
          $ du .
          64      ./class
          4       ./assignments/vie
          3       ./assignments/other
          34      ./assignments
          35      ./quizes
          254     .
          
        • /etc/fsck - file system consistency check and interactive repair.
      6. NFS
        Files may be mounted across systems using NFS (network file system). Exported files systems are in /etc/export.

    5. Controlling users.

      1. passwd and group
        1. User account information is stored in /etc/apsswd
        2. Each line is /tec/passwd contains a username, password, UID, GID, user's name, home directory, and default shell.
        3. Group information is stored in /etc/group.
        4. Each line in /etc/group contains a group name, group password, GID, and group membership list.
        5. The passwd and group files are world readable.

      2. Shadow files. (Linux).
        1. To prevent users from obtaining encrypted passwords from passwd and group shadow files are implemented.
        2. Encrypted passwords are moved to a new file which is readable only by root.
        3. The shadow file for /etc/passwd is /etc/shadow.
        4. the shadow file for /etc/group is /etc/gshadow.

      3. User administration varies from UNIX system to system. All have implemented a set of commands for administartion of users and groups. Most Unix systems also offer a GUI interface for these tasks.

      4. Login sequence.
        1. getty - which sets the terminal mode for the user. getty is invoked by init opens and initializes a tty line, reads a login name and invokes login.
        2. login - logs in to the system. Checks the password and invokes the default shell.
        3. sh (ksh, bash etc). - the default shell invokes /etc/profile.
        4. /etc/profile - The system wide profile setup. Command sthtat you want every user to run every time they login in are placed in this file.
        5. $HOME/.profile - The users .profile environment.

    6. Multiuser processes.
      1. init is the process control initialization, it is started as the last step in the boot procedure. It runs a sequence of commands in the script /etc/inittab.
         
        :
        : Note - initdefault and sysinit should be the first and second entry.
        :
        Identifier:RunLevel:Action:Command
        init:2:initdefault:
        brc::sysinit:/sbin/rc.boot 3 >/dev/console 2>&1 # Phase 3 of system boot
        rc:2:wait:/etc/rc 2>&1 | alog -tboot > /dev/console # Multi-User checks
        fbcheck:2:wait:/usr/sbin/fbcheck 2>&1 | alog -tboot > /dev/console 
        srcmstr:2:respawn:/usr/sbin/srcmstr # System Resource Controller
        rctcpip:2:wait:/etc/rc.tcpip > /dev/console 2>&1 # Start TCP/IP daemons
        rcnfs:2:wait:/etc/rc.nfs > /dev/console 2>&1 # Start NFS Daemons
        cron:2:respawn:/usr/sbin/cron
        rclocal:2:wait:/etc/rc.local >/dev/console 2>&1 # Start etc/rc.local
        
      2. sched is the process that controls allocation of the cpu.
      3. cron is the clock daemon, it executes commands at specified dates and times. The cron daemon reads the files in /usr/spool/cron/crontabs for commands and when to execute them.

        #==============================================================================
        # FIELD: USAGE
        #     1: minute (0-59)
        #     2: hour (0-23)
        #     3: day of month (1-31)
        #     4: month (1-12)
        #     5: day of week (0-6)
        #     6: shell command
        #==============================================================================
        01  3 * * * /etc/lpp/diagnostics/bin/run_ela   1>/dev/null 2>/dev/null
        01  4 * * * /etc/lpp/diagnostics/bin/test_batt 1>/dev/null 2>/dev/null
        0  11 * * * /usr/bin/errclear -d S,O 30
        0  12 * * * /usr/bin/errclear -d H 90
        #==============================================================================
        0   2 * * 6 /crontab_scripts/cron_wrapper  /crontab_scripts/garbage_collector
        0  19 * * 4 /crontab_scripts/cron_wrapper  /crontab_scripts/aix_backup
        1   0 * * 0 /crontab_scripts/cron_wrapper  /crontab_scripts/save_gn_log
        30  1 * * * /crontab_scripts/cron_wrapper  /crontab_scripts/sboer.1
        #==============================================================================
        

        #!/bin/ksh
        #  File Name:   cron_wrapper
        #
        #  Description: Shell script which calls another shell script, captures standard
        #               out and standard error to a file, and mails the file to "ask" 
        #
         
        $1 > /tmp/mailfile$$ 2>&1          # execute the command capture the output
        
        SUBJECT="`uname -n`:`basename $1`" # get the name of the command
        
        mail -s "$SUBJECT" ask  < /tmp/mailfile$$  # mail output to ask
        
        rm /tmp/mailfile$$                  # remove temporary file
        #-------------------------------------------------------------------------------
        

    © Allan Kochis Last revision 11/27/2001