⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0044-0046.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:


<HTML>

<HEAD>

<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:System Startup and Shutdown</TITLE>

<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>

 -->




<!-- ISBN=0672311739 //-->

<!-- TITLE=RED HAT LINUX 2ND EDITION //-->

<!-- AUTHOR=DAVID PITTS ET AL //-->

<!-- PUBLISHER=MACMILLAN //-->

<!-- IMPRINT=SAMS PUBLISHING //-->

<!-- PUBLICATION DATE=1998 //-->

<!-- CHAPTER=04 //-->

<!-- PAGES=0037-0052 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="0041-0043.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0047-0049.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-44"><P>Page 44</P></A>













<P>Both of these are manual approaches. But since the Red Hat folks have taken such great

pains to make system administration easier, why not take advantage of point-and-click

convenience? When you use tksysv, you can see at one glance which processes are going to be enabled

or disabled at each runlevel.

</P>









<P>The tksysv client, written in tcl/tk, is a runlevel editor. You simply select a service and

then click the Add or Remove button. You can also select a service in the Start or Stop section of

the dialog, and then click the Edit button to assign a number to the service in order to change

the order in which the process is started or stopped when entering or leaving a particular runlevel.

</P>









<P>Using tksysv sure beats doing everything by hand. But be careful! Making changes by

hand-editing the default runlevel for /etc/inittab or using

tksysv to change runlevels can put your system into an unusable state. Here's a handy tip from the help menu in

tksysv:

</P>









<P>&quot;If you do mess up, you can get in to fix it by rebooting and doing

</P>





<!-- CODE SNIP //-->

<PRE>

LILO boot: linux single

</PRE>

<!-- END CODE SNIP //-->











<P>This should allow you to boot into single-user mode so you can fix it.&quot;

</P>









<H3><A NAME="ch04_ 15">

Shutting Down the Linux System

</A></H3>









<P>By now you've learned not only how Linux starts, but also a little bit about how it shuts

down. If you look at the scripts in runlevel 0, you'll find a number of services being shut down,

followed by the killing of all active processes, and finally, the halt script in

inet.d executing the shutdown.

</P>









<P>The halt script is used to either halt or reboot your system, depending on how it is called.

But what happens during a shutdown? If you're familiar with other operating systems such as

DOS, you remember that all you had to do was close any active application and then turn off

the computer. Although Linux is easy to use, shutting down your computer is not as simple

as turning it off. (Although you can try this if you wish, you do so at your own risk!) There are

a number of processes that must take place before you or Linux turns off your computer.

Let's take a look at some of the commands involved.

</P>









<H5><A NAME="ch04_ 16">

shutdown

</A></H5>









<P>Although many people use Linux as a single user on a single computer, many of us use

computers either on a distributed or shared network. If you've ever been working under a

tight deadline in a networked environment, then you know the dreadful experience of seeing

the &quot;System is going down in 5 minutes!&quot; message from the system administrator. You might

also know the frustration of working on a system on which the system administrator is trying

to perform maintenance, suffering seemingly random downtimes or frozen tasks.

</P>









<P>Luckily for most users, these jobs are performed

during off hours, when most people are home with their loved ones, or fast asleep in bed.

Unluckily for sysadmins, this is the perfect time for

</P>



<A NAME="PAGENUM-45"><P>Page 45</P></A>









<P>

system administration or backups, and one of the top reasons for the

alt.sysadmin.recovery newsgroup!

</P>









<P>The primary command to stop Linux is the

shutdown command. Like most UNIX commands,

shutdown has a number of options. Curiously, no man page for the

shutdown command is included in Red Hat Linux 4.2, but you can find its command-line syntax because it displays

a small help message if you use an illegal option. Thanks to the

programmer, here it is:

</P>





<!-- CODE //-->

<PRE>

Usage:    shutdown [-krhfnc] [-t secs] time [warning message]

                  -k:      don't really shutdown, only warn.

                  -r:      reboot after shutdown.

                  -h:      halt after shutdown.

                  -f:      do a `fast' reboot.

                  -n:      do not go through &quot;init&quot; but go down real fast.

                  -c:      cancel a running shutdown.

                  -t secs: delay between warning and kill signal.

** the &quot;time&quot; argument is mandatory! (try &quot;now&quot;) **

</PRE>

<!-- END CODE //-->











<P>To properly shutdown your system immediately, use

</P>





<!-- CODE SNIP //-->

<PRE>

# shutdown -h now

</PRE>

<!-- END CODE SNIP //-->











<P>If you want to wait for a while, use the -t option. If you want to restart your computer, use

</P>





<!-- CODE SNIP //-->

<PRE>

# shutdown -r now

</PRE>

<!-- END CODE SNIP //-->











<P>The lack of documentation for shutdown in the Red Hat Linux can be troublesome, but

even more curious is the presence of two text strings embedded in the program:

</P>



<!-- CODE SNIP //-->

<PRE>

&quot;You don't exist. Go away.&quot;

&quot;(Well hello Mr. Tyler - going DOWN?)&quot;

</PRE>

<!-- END CODE SNIP //-->











<P>which were found by executing:

</P>





<!-- CODE SNIP //-->

<PRE>

# strings /sbin/shutdown

</PRE>

<!-- END CODE SNIP //-->











<P>Hint: To find out about &quot;You don't exist. Go

away.&quot;, see Ian Jackson's Linux Frequently Asked Questions with

Answers. You should be able to find a copy at

ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO.

</P>









<H4><A NAME="ch04_ 17">

halt and reboot

</A></H4>









<P>There are two other commands that will also stop or restart your system: the

halt and reboot commands. reboot is a symbolic link to

halt. halt notifies the kernel of a shutdown or

reboot. Although you should always use shutdown to restart your system, there is another

command you can use: the Vulcan neck pinch,

ctrlaltdel.

</P>









<P>If you use the keyboard form of this command, you'll find that Linux uses the following

command:

</P>





<!-- CODE SNIP //-->

<PRE>

# shutdown -t3 -r now

</PRE>

<!-- END CODE SNIP //-->











<P>If you use the command-line form of this approach, you have two options: hard or soft.

Because a hard reset will restart your computer without calling the

sync command, a soft reset is

</P>



<A NAME="PAGENUM-46"><P>Page 46</P></A>









<P>

preferred. Why? Because sync updates the inodes of your files, or structure representations

of each of your files. If you exit Linux without updating this information, Linux could lose

track of your files on disk, and that spells disaster!

</P>





<P>

<P>

<P>

<P>

<P>

<P>



<CENTER>

<TABLE BGCOLOR="#FFFF99">

<TR><TD><B>

NOTE

</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

The only time you'll want to risk shutting down Linux through a hard reset or the

power-off switch on your computer is if you can't quickly kill a destructive process, such as

an accidental rm -fr /*.

</BLOCKQUOTE></TD></TR>

</TABLE></CENTER>

</P>

<P>By now you should know that exiting Linux properly can help you avoid problems with

your system. But what happens if something goes wrong? In the next section you'll learn about 

preventive measures, how to maintain your filesystem, and how to recover and overcome 

problems.

</P>









<H3><A NAME="ch04_ 18">

When the System Crashes

</A></H3>









<P>The best time to deal with a system crash is before the crash happens. This means being

prepared with a good backup plan, good backups, emergency boot disks, or copies of

important files. These issues are covered in this section, along with tips and hints for maintaining

your filesystem integrity and system security.

</P>









<P>First, here are some Do's and Don'ts to avoid problems:

</P>









<UL>

<LI>          Don't use Linux as the root user.

<LI>          Do make a backup after a clean install and setup.

<LI>          Do create a set of emergency boot disks with your current kernel.

<LI>          Don't just turn off your computer when done.

<LI>          Do use the shutdown command.

<LI>          Do consider using an uninterruptible power supply.

<LI>          Don't disable e2fsck in /etc/rc.d/rc.sysinit.

<LI>          Do use fsck or badblocks to check floppies.

<LI>          Don't run fsck on mounted filesystems.

<LI>          Do make backups of important files on floppy disks.

<LI>          Don't worry about fragmentation of your Linux partitions.

<LI>          Do use your filesystem tools.

<LI>          Don't fill your hard drive with unnecessary programs.

<LI>          Do consider using flash RAM.

<LI>          Do read Lars Wirzenius's Linux System Administrators' Guide 0.5.

</UL>



<P><CENTER>

<a href="0041-0043.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0047-0049.html">Next</A>

</CENTER></P>









</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -