CSC128: Introduction to UNIX

System Administration 2


System Backups

One of the most important tasks of a sysadmin is to back up the data, so that in the case of an emergency, everyone's work still exists.  

Often, a full backup is done every week or month, and incremental backups are done once or twice a day.  

Depending on the size and purpose of a filesystem, different media are used to store the backups:  magnetic tape, CD-R, other hard drive(s), etc.

It is important to maintain backups in an orderly way, so that users can easily be provided with the backup of files they have inadvertantly erased.

Programs that are often used for making backups:
tar
gzip
cpio
dump/restore
pax

Users

The sysadmin controls the user accounts.  User accounts are controlled from the /etc/passwd file on most systems.  Other systems use a centralized server on the network to control user accounts (LDAP, Kerberos).

Often, a handy script exists on the system to simplify the task of creating, modifying, and removing users:  useradd, adduser, userdel, etc.


Packages

System application software needs to be installed and kept up-to-date.  Today, this is dealt with in a number of ways.

Tarball Source
Often, software is distributed for UNIX systems as a tarball (a file created by
tar and often gzip ) that holds a directory tree that contains the source code to an application.  The sysadmin must compile the source code, and then install the executable and support files into their proper places in the filesystem.

RPM
Under Linux, RPM's are often used instead of tarballs.  These hold precompiled versions of applications, and information as to where the files go in the filesystem.  The sysadmin doesn't need to go through the trouble of compiling and installing by hand, the
rpm program handles it all.  It is important to get a RPM file for your specific system and distribution of Linux, or it may not work well or at all.

Network Pull
Other systems use methods of pulling the source or binary directly from a server that is kept updated with versions of applications specifically modified to work well on specific systems.  Examples include Debian GNU/Linux's apt-get program, BSD Ports or Packages, or even the Cygwin setup program.  These methods are all able to check the current state of the system, and automatically update all programs that have newer or fixed versions.  This can be very handy, but it's still up to the syadmin to know what's going on with the system to the last detail.


Filesystems
The file /etc/fstab contains a list of filesystems that are automatically mounted to the filesystem and checked for integrity by fsck at each boot-up.  The commands mount and umount are used to manually mount a device to a point in the filesystem.  This includes such things as CD-ROMs:  to use a CD-ROM, the disc must be mounted before use, and umount ed before it can be removed.  (A new utility called automount can do this automatically, if you trust it to.)

The following commands are useful for monitoring disk usage:
df
Disk Free:  lists the free space on all mounted filesystems.


du
Disk Usage:  lists the space used by each directory specified.

Kernel Configuration

The kernel should be kept as small as possible, while still having all the functionality needed for the system.  Most kernels (including the Linux kernel) are able to be altered so that they only have functions they need, and none that they don't need.  

Some kernels come with source code, and so parts of the code can be added or removed, and then the kernel can be recompiled so that it only has functions that are needed.

Proprietary UNIX systems usually do not come with source code; the sources are a closely guarded secret.  These systems often use modules Many features of the kernel are in seperate files called modules, which can be loaded into memory if they are needed.  If they aren't needed, they don't waste any memory.  The drawback is that they take time to load, and they don't know to load until the user has requested their functions, which can make the system seem slow.

Our current version of Slackware supports modules. Different modules can be enabled by un-commenting their line in /etc/rc.d/rc.modules. The file /etc/rc.d/rc.modules is the first file that is read at system startup after /etc/rc.d/rc.S  

Both methods are supported by modern Linux kernels.  Often the source code (if installed) can be found in:
/usr/src/linux/
...or some similar directory, and the kernel is called vmlinuz or vmlinux . Type make xconfig on a command line in the kernel source directory, and a graphical X interface will show you the many many many options available when compiling a new kernel.


Important Files

/etc/motd
The Message of the Day, it is displayed whenever a user logs in.

/etc/profile
This is a script file.  When bash is started, the first thing it does is execute the commands in this file.  It then executes the startup scripts in the user's home directory, (~/.bash_profile ~/.bash_login and  ~/.profile, in that order).
      
/etc/rc.d/rc.local
This file contains scripts that are specific to this machine. If the system administrator installs software locally, s/he should probably edit this file to start the service that is unique to this machine.

/etc/fstab
This file contains a list (tabulature) of all the filesystems that will be automatically mounted and checked by fsck during the boot process.

/etc/passwd
This file contains user information;  each line represents a separate user account and contains information such as the username, the userid, the home directory, and the startup shell.

/etc/group
This file contains information about groups, used for group permissions.  See p 599 in the text for more information.

Special Files

In the directory /dev exist many special files.  Most interface with devices, but some are special ways of interacting with the kernel.  Just as directories are designated with a "d" in the first column of a long listing, these special files have special designations.  "b" stands for block device , a type of device that deals with data as blocks of characters.  "c" stands for character device, a type of device that deals with data as individual bytes.  "p"  stands for a FIFO or Named Pipe, a special type of file used by processes on the same machine to exchange information.

Examples:
/dev/hda1
A block device representing first (1) partition of the first (a) IDE device (usually a hard drive).

/dev/null
A character device that represents nothing and nowhere.  Anything redirected to this device will disappear.  Any program that redirects from this device will only get an End-Of-File (EOF) character.

/dev/random
A character device that returns a stream of random data.

/dev/zero
A character device that returns a stream of zeros.


Pipes and Sockets

As mentioned above, a special type of file called a Named Pipe can be used by processes running on the same machine to communicate with each other.

When a process wishes to communicate with a process on a different machine, sockets are used.  These are gateways to the network and the internet, whereby any process on a connected computer can communicate with any listening process anywhere else on the network.