UNIX / Linux Tutorial
Chapter 2
System Administration
2.1 The Root Account | 2.2 Booting The System | 2.2.1 Using LILO
2.3 Shutting Down
System Administration This chapter covers the most important things that you need to know about system administration under Linux in sufficient detail to start using the system comfortably. In order to keep the chapter manageable, it covers just the basics and omits many important details. The Linux System Administrator's Guide, by Lars Wirzenius (see Appendix A) provides considerably more detail on system administration topics. It will help you understand better how things work and hang together. At least, skim through the SAG so that you know what it contains and what kind of help you can expect from it. 2.1 The Root Account Linux differentiates between different users. What they can do to each other and the system is regulated. File permissions are arranged so that normal users can't delete or modify files in directories like /bin and /usr/bin. Most users protect their own files with the appropriate permissions so that other users can't access or modify them. (One wouldn't want anybody to be able to read one's love letters.) Each user is given an account that includes a user name and home directory. In addition, there are special, system defined accounts which have special privileges. The most important of these is the root account, which is used by the system administrator. By convention, the system administrator is the user, root. There are no restrictions on root. He or she can read, modify, or delete any file on the system, change permissions and ownerships on any file, and run special programs like those which partition a hard drive or create file systems. The basic idea is that a person who cares for the system logs in as root to perform tasks that cannot be executed as a normal user. Because root can do anything, it is easy to make mistakes that have catastrophic consequences. If a normal user tries inadvertently to delete all of the files in /etc, the system will not permit him or her to do so. However, if root tries to do the same thing, the system doesn't complain at all. It is very easy to trash a Linux system when using root. The best way to prevent accidents is: Sit on your hands before you press Enter for any command that is non-reversible. If you're about to clean out a directory, re-read the entire command to make sure that it is correct. Use a different prompt for the root account. root's .bashrc or .login file should set the shell prompt to something different than the standard user prompt. Many people reserve the character "#" in prompts for root and use the prompt character "$" for everyone else. Log in as root only when absolutely necessary. When you have finished your work as root, log out. The less you use the root account, the less likely you are to damage the system. You are less likely to confuse the privileges of root with those of a normal user. Picture the root account as a special, magic hat that gives you lots of power, with which you can, by waving your hands, destroy entire cities. It is a good idea to be a bit careful about what you do with your hands. Because it is easy to wave your hands in a destructive manner, it is not a good idea to wear the magic hat when it is not needed, despite the wonderful feeling. 2.2 Booting The System Some people boot Linux with a floppy diskette that contains a copy of the Linux kernel. This kernel has the Linux root partition coded into it, so it knows where to look for the root file system. This is the type of floppy created by Slackware during installation, for example. To create your own boot floppy, locate the kernel image on your hard disk. It should be in the file /vmlinuz,or/vmlinux. In some installations, /vmlinuz is a soft link to the actual kernel, so you may need to track down the kernel by following the links. Once you know where the kernel is, set the root device of the kernel image to the name of your Linux root partition with the rdev command. The format of the command is: rdev kernel-name root-device where kernel-name is the name of the kernel image, and root-device is the name of the Linux root partition. For example, to set the root device in the kernel /vmlinuz to /dev/hda2, use the command: # rdev /vmlinuz /dev/hda2 rdev can set other options in the kernel, like the default SVGA mode to use at boot time. The command: # rdev -h prints a help message on the screen. After setting the root device, simply copy the kernel image to the floppy. Before copying data to any floppy, however, it's a good idea to use the MS-DOS FORMAT.COM or the Linux fdformat program to format the diskette. This lays down the sector and track information that is appropriate to the floppy's capacity. Device driver files, as mentioned earlier, reside in the /dev directory. To copy the kernel in the file /etc/Image to the floppy in /dev/fd0, use the command: # cp /vmlinuz /dev/fd0 This floppy should now boot Linux. 2.2.1 Using LILO LILO is a separate boot loader which resides on your hard disk. It is executed when the system boots from the hard drive and can automatically boot Linux from a kernel image stored there. LILO can also be used as a first-stage boot loader for several operating systems, which allows you to select the operating system you to boot, like Linux or MS-DOS. With LILO, the default operating system is booted unless you press Shift during the boot-up sequence, or if the prompt directive is given in the lilo.conf file. In either case, it will be provide you with a boot prompt, where you type the name of the operating system to boot (such as "linux"or"msdos"). If you press Tab at the boot prompt, a list of operating systems that the system knows about will be provided. The easy way to install LILO is to edit the configuration file, /etc/lilo.conf.The command: # /sbin / lilo rewrites the modified lilo.conf configuration to the boot sector of the hard disk, and must be run every time you modify lilo.conf. The LILO configuration file contains a "stanza" for each operating system that you want to boot. The best way to demonstrate this is with an example. The lilo.conf file below is for a system which has a Linux root partition on /dev/hda1 and a MS-DOS partition on /dev/hda2 : # Tell LILO to modify the boot record on /dev/hda (the first # non-SCSI hard drive). If you boot from a drive other than # /dev/hda, change the following line. boot = /dev/hda # Set a sane videomode vga = normal # Set the delay in milli-seconds. This is the time you have to # press the 'SHIFT' key to bring up the LILO: prompt if you # haven't specified the 'prompt' directive. delay = 60 # Name of the boot loader. No reason to modify this unless you're # doing some serious hacking on LILO. install = /boot/boot.b # This forces LILO to prompt you for the OS you want to boot. # A 'TAB' key at the LILO: prompt will display a list of the OSs # available to boot according to the names given in the 'label=' # directives below. prompt # Have LILO perform some optimization. compact # Stanza for Linux root partition on /dev/hda1. image = /vmlinuz # Location of kernel label = linux # Name of OS (for the LILO boot menu) root = /dev/hda1 # Location of root partition read-only # Mount read only # Stanza for MSDOS partition on /dev/hda2. other = /dev/hda2 # Location of partition table = /dev/hda # Location of partition table for /dev/hda2 label = msdos # Name of OS (for boot menu) The first operating system stanza is the default operating system for LILO to boot. Also note that if you use the "root =" line, above, there's no reason to use rdev to set the root partition in the kernel image. LILO sets it at boot time. The Microsoft Windows '95/98 installer will overwrite the LILO boot manager. If you are going to install Windows '95/98 on your system after installing LILO, make sure to create a boot disk first . With the boot disk, you can boot Linux and re-install LILO after the Windows '95 installation is completed. This is done simply by typing, as root, the command /sbin/lilo, as in the step above. Partitions with Windows '95/98 are configurable to boot with LILO using the same lilo.conf entries that are used to boot the MS-DOS partition. The Linux FAQ provides more information on LILO, including how to use LILO to boot with the OS/2 Boot Manager. 2.3 Shutting Down Shutting down a Linux system can be tricky. You should never simply turn off the power or press the reset switch. The kernel keeps track of the disk read/write data in memory buffers. If you reboot the system without giving the kernel a chance to write its buffers to disk, you can corrupt the file systems. Other precautions are taken during shutdown as well. All processes are sent a signal that allows them to die gracefully (by first writing and closing all files, for example). File systems are unmounted for safety. If you wish, the system can also alert users that the system is going down and give them a chance to log off. The easiest way to shut down is with the shutdown command. The format of the command is: shutdown time warning-message The time argument is the time to shut down the system (in the format hh:mm:ss), and warning-message is a message displayed on all user's terminals before shutdown. Alternately, you can specify the time as "now", to shut down immediately. The -r option may be given to shutdown to reboot the system after shutting down. For example, to shut down and reboot the system at 8:00 pm, use the command: # shutdown -r 20:00 The command halt may be used to force an immediate shutdown without any warning messages or grace period. halt is useful if you're the only one using the system and want to shut down and turn off the machine. Don't turn off the power or reboot the system until you see the message: The system is halted It is very important that you shut down the system, "cleanly," using the shutdown or halt command. On some systems, pressing Ctrl - Alt - Del will be trapped and cause a shutdown. On other systems, using the "Vulcan nerve pinch" will reboot the system immediately and cause disaster.
1.1 Introduction 1.2.10 Referring To Home Directories 1.3.4 Copying Files
1.6 Exploring The File System 1.8 Wildcards 1.9.3 Pipes 1.10.3 Permissions Dependencies
1.12.4 Stopping And Restarting Jobs 1.13.3 Inserting Text 1.13.9 Including Other Files
1.14.3 Shell Initialization Scripts System Administration 2.3.1 The /etc/imitate file
2.4 Managing File Systems 2.6 Managing Users 2.6.5 Groups 2.7.2 gzip and compress
2.8.3 Making Backups To Tape Devices 2.9.1 Upgrading The Kernel
2.9.3 Installing A Device Driver Module
BOOK: LINUX QUICK COMMAND REFERENCE
http://personal.atl.bellsouth.net/~psadler
© copyright KnowledgeWorks, Inc. (2001)