📄 ch38.htm
字号:
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<UL>
<LI><A HREF="#Heading1">- 38 -</A>
<UL>
<LI><A HREF="#Heading2">System Administration Basics</A>
<UL>
<LI><A HREF="#Heading3">The root Account</A>
<LI><A HREF="#Heading4">Starting and Stopping the System</A>
<UL>
<LI><A HREF="#Heading5">Booting from a Floppy</A>
<LI><A HREF="#Heading6">Using LILO to Boot</A>
<LI><A HREF="#Heading7">Shutting Down Linux</A>
</UL>
<LI><A HREF="#Heading8">WARNING</A>
<LI><A HREF="#Heading9">Mounting File Systems</A>
<UL>
<LI><A HREF="#Heading10">Mounting a Floppy</A>
<LI><A HREF="#Heading11">Creating a New File System</A>
<LI><A HREF="#Heading12">Unmounting File Systems</A>
<LI><A HREF="#Heading13">Checking File Systems</A>
<LI><A HREF="#Heading14">Using a File as Swap Space</A>
</UL>
<LI><A HREF="#Heading15">Compressing Files with gzip and compress</A>
<LI><A HREF="#Heading16">Using tar</A>
<LI><A HREF="#Heading17">Backups</A>
<LI><A HREF="#Heading18">Setting Up Your System</A>
<UL>
<LI><A HREF="#Heading19">Setting the System Name</A>
<LI><A HREF="#Heading20">Using a Maintenance Disk</A>
<LI><A HREF="#Heading21">Forgetting the root Password</A>
</UL>
<LI><A HREF="#Heading22">WARNING</A>
<UL>
<LI><A HREF="#Heading23">Setting the Login Message</A>
</UL>
<LI><A HREF="#Heading24">Summary</A>
</UL>
</UL>
</UL>
<P>
<HR SIZE="4">
<H2 ALIGN="CENTER"><A NAME="Heading1<FONT COLOR="#000077">- 38 -</FONT></H2>
<H2 ALIGN="CENTER"><A NAME="Heading2<FONT COLOR="#000077">System Administration
Basics</FONT></H2>
<P><I>by Tim Parker</I></P>
<P>IN THIS CHAPTER</P>
<UL>
<LI>The root Account
<P>
<LI>Starting and Stopping the System
<P>
<LI>Mounting File Systems
<P>
<LI>Compressing Files with gzip and compress
<P>
<LI>Using tar
<P>
<LI>Backups
<P>
<LI>Setting Up Your System
</UL>
<P>So far in this book, you've seen how to use Linux for many different tasks. However,
there are some issues we haven't dealt with because they are used rarely, or only
by a single administrator (who may be the only user). This chapter looks at simple
system administration tasks, including the following:
<UL>
<LI>Starting and shutting down the system properly
<P>
<LI>Managing the disk partitions
<P>
<LI>Making backups
<P>
<LI><TT>gzip</TT>, <TT>compress</TT>, and <TT>tar</TT>
<P>
<LI>Message of the day
<P>
<LI>Emergency boot floppies
</UL>
<P>Of course, we can't cover everything you need to know to run a system efficiently.
Instead, we will look at the basic information and utilities and leave you to experiment.
For more details, check the documentation files with your Linux operating system.
Better yet, consider purchasing a good UNIX system administration book, such as Linux
System Administrator's Survival Guide (Sams Publishing, 1995). Much of the information
in a UNIX book will be applicable to Linux.
<H3 ALIGN="CENTER"><A NAME="Heading3<FONT COLOR="#000077">The root Account</FONT></H3>
<P>The <TT>root</TT> login, as you probably know, has no limitations at all. It can
do anything anywhere, access any files it wants, and control any processes. This
power has its price, though: Any mistake can be disastrous, sometimes resulting in
damage to the entire operating system.</P>
<P>A mystique has built up in the UNIX community about the <TT>root</TT> login, because
it holds unlimited power over the system. The tendency to want to use this superuser
login is overwhelming for many. However, a simple <TT>rm</TT> command in the wrong
place can spell many hours of trouble.</P>
<P>For this reason, the <TT>root</TT> account should be employed only for limited
system use, and then only when its power is necessary (such as when rebuilding a
kernel, installing new software, or setting up new file systems). As a general rule,
you should not use the <TT>root</TT> account for routine tasks.</P>
<P>Naturally, many people use <TT>root</TT> for their daily Linux sessions, ignoring
any advice because they think they won't make mistakes. In truth, everyone makes
a mistake occasionally. Check with any UNIX system administrator and you'll find
that accidents happen with the <TT>root</TT> account. (I have managed to delete entire
file systems more than once while trying to do two things at the same time.) Although
many people will ignore the rule about using <TT>root</TT> only when necessary, most
of them eventually find out why this rule is important!
<H3 ALIGN="CENTER"><A NAME="Heading4<FONT COLOR="#000077">Starting and Stopping
the System</FONT></H3>
<P>There are several ways of booting the Linux operating system, as well as a few
ways to safely shut it down. Some were mentioned earlier in this book. Because Linux
can be installed in many different ways, there is no single "right" method
of booting the operating system, so we must look at both hard-disk-based and floppy-disk-based
boot procedures.
<H4 ALIGN="CENTER"><A NAME="Heading5<FONT COLOR="#000077">Booting from a Floppy</FONT></H4>
<P>A boot floppy, as its name implies, is a floppy disk that boots the Linux kernel.
A boot floppy has the <TT>root</TT> partition installed on the floppy itself instead
of the hard drive (although both may co-exist). Without the <TT>root</TT> partition,
Linux would be unable to find the hard drives for the rest of the operating system.</P>
<P>You can create Linux boot floppies with the setup routine included in most distributions
of the operating system. Check the documentation or information files that came with
your Linux distribution, if there are any. Alternatively, most Linux setup utilities
have a menu-driven interface that prompts you for a boot floppy setup when you rebuild
or reconfigure the kernel. You should use this procedure to make a boot floppy, which
is also useful for emergencies.</P>
<P>In most cases, a boot floppy is used only in emergencies when your system won't
start up normally. The boot floppy enables you to load Linux, and then mount the
hard drives that are causing the problem to check for damage. Luckily, this is not
required very often. If you haven't used LILO to choose the partition to boot or
set your boot sequence to Linux by default, you may need the boot floppy to start
up Linux. In this case, the boot floppy is much like a DOS boot floppy.</P>
<P>You can create a boot floppy from scratch by copying over the kernel image from
the hard drive. The kernel image is usually in the file <TT>vmlinuz</TT>, <TT>vmlinux</TT>,
<TT>Image</TT>, or <TT>/etc/Image</TT>, depending on the distribution of Linux. The
Slackware distribution uses <TT>vmlinuz</TT>, which is a compressed kernel (hence
the <TT>z</TT> in the name). Compressed kernels uncompress themselves as they are
loaded into memory at boot time. The <TT>vmlinuz</TT> image expands to <TT>vmlinux</TT>.
(Compressed kernels take up less disk space; that's why they are used.)</P>
<P>After you have identified the kernel, you can set the <TT>root</TT> device in
the kernel image to point to the <TT>root</TT> partition on either the floppy or
hard drive. In this case, we want the floppy. The root partition is set with the
<TT>rdev</TT> command, whose format is as follows:<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">rdev kernelname device
</FONT></PRE>
<P>kernelname is the name of the kernel image, and device is the name of the Linux
<TT>root</TT> partition. To set a floppy boot device with the file <TT>vmlinuz</TT>,
the command would be<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">rdev vmlinuz /dev/fd0
</FONT></PRE>
<P>for the first floppy on the system. You can set other parameters with <TT>rdev</TT>
as well if you want to change system defaults during boot. Check the <TT>rdev</TT>
man page for the <TT>rdev</TT> help file for complete information.</P>
<P>As a final step in creating the boot floppy, copy the kernel image to the floppy
disk. You should use a preformatted diskette (format with DOS if necessary) to allow
the Linux routines to identify the type of diskette and its density. To copy the
<TT>vmlinuz</TT> kernel to the first floppy drive, use this command:<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">cp vmlinuz /dev/fd0
</FONT></PRE>
<P>The floppy should now be ready to boot the system. You might not be able to boot
the system without the floppy if you changed the location of the <TT>root</TT> partition.
You can change the <TT>root</TT> partition back to the hard drive with the <TT>rdev</TT>
command after completing the boot floppy, which enables you to boot from either.
This can be useful when you have diskettes for several different boot configurations.
You can also create the boot floppy from the Linux <TT>setup</TT> program.
<H4 ALIGN="CENTER"><A NAME="Heading6<FONT COLOR="#000077">Using LILO to Boot</FONT></H4>
<P>LILO is a program that resides in the boot sector of your hard drive and allows
Linux to be booted from the hard disk either after you tell it to or after a default
number of seconds has elapsed.</P>
<P>LILO can also be used with other operating systems such as OS/2 and DOS. If you
have LILO set to autoboot Linux, you must interrupt the process by pressing the Ctrl,
Alt, or Shift keys when the bootup is started if you want to boot into another operating
system. This displays a boot prompt that enables you to specify another operating
system.</P>
<P>If LILO is set to allow a given time before it boots into Linux, you can use the
Ctrl-Alt-Shift sequence to interrupt the boot process before the timer expires and
Linux starts loading. Finally, if LILO is set to not autoboot into Linux, but to
wait for explicit instructions, you must press Enter to boot Linux or type the name
of the other operating system.</P>
<P>Some Linux distributions have a configuration file in the directory <TT>/etc/lilo</TT>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -