587 lines
8.3 KiB
HTML
587 lines
8.3 KiB
HTML
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Shutting Down/Rebooting the System</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
|
|
REL="HOME"
|
|
TITLE="GNU/Linux Command-Line Tools Summary"
|
|
HREF="book1.htm"><LINK
|
|
REL="UP"
|
|
TITLE="Controlling the system"
|
|
HREF="c4975.htm"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="Controlling the system"
|
|
HREF="c4975.htm"><LINK
|
|
REL="NEXT"
|
|
TITLE="Controlling Processes"
|
|
HREF="x5368.htm"></HEAD
|
|
><BODY
|
|
CLASS="SECT1"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
SUMMARY="Header navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>GNU/Linux Command-Line Tools Summary</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="c4975.htm"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
>Chapter 9. Controlling the system</TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x5368.htm"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="SECT1"
|
|
><H1
|
|
CLASS="SECT1"
|
|
><A
|
|
NAME="SHUTTING-DOWN"
|
|
></A
|
|
>Shutting Down/Rebooting the System</H1
|
|
><P
|
|
></P
|
|
><DIV
|
|
CLASS="VARIABLELIST"
|
|
><DL
|
|
><DT
|
|
>shutdown now</DT
|
|
><DD
|
|
><P
|
|
><A
|
|
NAME="AEN5159"
|
|
></A
|
|
>Shutdown the computer immediately (don't power down<A
|
|
NAME="AEN5161"
|
|
></A
|
|
>). Note that in <SPAN
|
|
CLASS="PRODUCTNAME"
|
|
>UNIX</SPAN
|
|
> <A
|
|
NAME="AEN5164"
|
|
></A
|
|
>systems this kind of shutdown <A
|
|
NAME="AEN5166"
|
|
></A
|
|
>means to go to “ single-user mode”.<A
|
|
NAME="AEN5168"
|
|
></A
|
|
><A
|
|
NAME="AEN5170"
|
|
></A
|
|
> Single-user mode is a mode where only the administrator <A
|
|
NAME="AEN5172"
|
|
></A
|
|
>(root) has access<A
|
|
NAME="AEN5174"
|
|
></A
|
|
> to the computer, this mode <A
|
|
NAME="AEN5176"
|
|
></A
|
|
>is designed <A
|
|
NAME="AEN5178"
|
|
></A
|
|
>for maintenance <A
|
|
NAME="AEN5180"
|
|
></A
|
|
>and is often used for repairs.<A
|
|
NAME="AEN5182"
|
|
></A
|
|
></P
|
|
><P
|
|
>For example this would take you to single user mode </P
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
>shutdown now</PRE
|
|
></DD
|
|
><DT
|
|
>shutdown -h now</DT
|
|
><DD
|
|
><P
|
|
><A
|
|
NAME="AEN5190"
|
|
></A
|
|
>Shutdown <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>(-h<A
|
|
NAME="AEN5193"
|
|
></A
|
|
> = halt) </I
|
|
></SPAN
|
|
>the computer immediately. It begins the shutdown procedure,<A
|
|
NAME="AEN5195"
|
|
></A
|
|
> press
|
|
<B
|
|
CLASS="KEYCAP"
|
|
>CTRL</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>C</B
|
|
>
|
|
<A
|
|
NAME="AEN5200"
|
|
></A
|
|
>
|
|
(break-key) to stop <A
|
|
NAME="AEN5202"
|
|
></A
|
|
>it. After the end of the command you can also leave a message <A
|
|
NAME="AEN5204"
|
|
></A
|
|
>in quotation<A
|
|
NAME="AEN5206"
|
|
></A
|
|
> marks <A
|
|
NAME="AEN5208"
|
|
></A
|
|
>which will be broad-casted <A
|
|
NAME="AEN5210"
|
|
></A
|
|
>to all users, for example:</P
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
>shutdown -h now "Warning system malfunction, self-destruct imminent"</PRE
|
|
><P
|
|
>This would halt <A
|
|
NAME="AEN5214"
|
|
></A
|
|
>the system and send <A
|
|
NAME="AEN5216"
|
|
></A
|
|
>the message <A
|
|
NAME="AEN5218"
|
|
></A
|
|
>to anyone who <A
|
|
NAME="AEN5220"
|
|
></A
|
|
>is currently logged<A
|
|
NAME="AEN5222"
|
|
></A
|
|
> in.</P
|
|
><DIV
|
|
CLASS="TIP"
|
|
><BLOCKQUOTE
|
|
CLASS="TIP"
|
|
><P
|
|
><B
|
|
>Shutting down at a particular time: </B
|
|
>You can also put a time that the system should shutdown instead of “now”. Typing “+x minutes<A
|
|
NAME="AEN5227"
|
|
></A
|
|
>” (any number <A
|
|
NAME="AEN5229"
|
|
></A
|
|
>of minutes <A
|
|
NAME="AEN5231"
|
|
></A
|
|
>is appropriate) or you can even set an exact <A
|
|
NAME="AEN5233"
|
|
></A
|
|
>time. For example to shutdown <A
|
|
NAME="AEN5235"
|
|
></A
|
|
>at <A
|
|
NAME="AEN5237"
|
|
></A
|
|
>11:50 type:
|
|
<PRE
|
|
CLASS="SCREEN"
|
|
>shutdown -h 11:50</PRE
|
|
></P
|
|
></BLOCKQUOTE
|
|
></DIV
|
|
><DIV
|
|
CLASS="NOTE"
|
|
><BLOCKQUOTE
|
|
CLASS="NOTE"
|
|
><P
|
|
><B
|
|
>Shutdown -h vs poweroff: </B
|
|
>On some systems, <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>shutdown -h </I
|
|
></SPAN
|
|
>and <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>halt </I
|
|
></SPAN
|
|
>do not actually turn the system's power off. On systems that do not power off with these commands use the <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>poweroff</I
|
|
></SPAN
|
|
><A
|
|
NAME="AEN5246"
|
|
></A
|
|
> command</P
|
|
></BLOCKQUOTE
|
|
></DIV
|
|
></DD
|
|
><DT
|
|
>halt</DT
|
|
><DD
|
|
><P
|
|
><A
|
|
NAME="AEN5252"
|
|
></A
|
|
>The same as <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>shutdown -h now</I
|
|
></SPAN
|
|
> doesn't take any options,<A
|
|
NAME="AEN5255"
|
|
></A
|
|
> this command simply shuts down immediately.</P
|
|
></DD
|
|
><DT
|
|
>shutdown -r now</DT
|
|
><DD
|
|
><P
|
|
><A
|
|
NAME="AEN5261"
|
|
></A
|
|
>Shutdown (<SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
> -r <A
|
|
NAME="AEN5264"
|
|
></A
|
|
>= reboot<A
|
|
NAME="AEN5266"
|
|
></A
|
|
></I
|
|
></SPAN
|
|
>) the computer immediately. It begins the reboot procedure,<A
|
|
NAME="AEN5268"
|
|
></A
|
|
> press <A
|
|
NAME="AEN5270"
|
|
></A
|
|
>
|
|
<B
|
|
CLASS="KEYCAP"
|
|
>CTRL</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>C</B
|
|
>
|
|
<A
|
|
NAME="AEN5275"
|
|
></A
|
|
>
|
|
(break-key) to stop <A
|
|
NAME="AEN5277"
|
|
></A
|
|
>it. After the end of the command you can also leave a message <A
|
|
NAME="AEN5279"
|
|
></A
|
|
>in quotation<A
|
|
NAME="AEN5281"
|
|
></A
|
|
> marks <A
|
|
NAME="AEN5283"
|
|
></A
|
|
>which will be broad-casted <A
|
|
NAME="AEN5285"
|
|
></A
|
|
>to all users, for example: </P
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
>shutdown -r now "Warning system rebooting, all files will be destroyed"</PRE
|
|
><P
|
|
>This would reboot the system and send <A
|
|
NAME="AEN5289"
|
|
></A
|
|
>the message <A
|
|
NAME="AEN5291"
|
|
></A
|
|
>to anyone who <A
|
|
NAME="AEN5293"
|
|
></A
|
|
>was logged in.</P
|
|
><DIV
|
|
CLASS="TIP"
|
|
><BLOCKQUOTE
|
|
CLASS="TIP"
|
|
><P
|
|
><B
|
|
>Rebooting at a particular time: </B
|
|
>You can also put a time that the system should reboot instead of “now”. Typing “+x minutes<A
|
|
NAME="AEN5298"
|
|
></A
|
|
>” (any number of minutes <A
|
|
NAME="AEN5300"
|
|
></A
|
|
>is appropriate) or you can even set <A
|
|
NAME="AEN5302"
|
|
></A
|
|
>an exact <A
|
|
NAME="AEN5304"
|
|
></A
|
|
>time. For example to reboot <A
|
|
NAME="AEN5306"
|
|
></A
|
|
>at 11:50 type:
|
|
<PRE
|
|
CLASS="SCREEN"
|
|
>shutdown -r 11:50</PRE
|
|
></P
|
|
></BLOCKQUOTE
|
|
></DIV
|
|
></DD
|
|
><DT
|
|
>reboot</DT
|
|
><DD
|
|
><P
|
|
>The same as <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>shutdown -r now</I
|
|
></SPAN
|
|
>, doesn't take any options, simply reboots <A
|
|
NAME="AEN5314"
|
|
></A
|
|
>the computer immediately. </P
|
|
></DD
|
|
><DT
|
|
><B
|
|
CLASS="KEYCAP"
|
|
>CTRL</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>ALT</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>DEL</B
|
|
>
|
|
<A
|
|
NAME="AEN5322"
|
|
></A
|
|
></DT
|
|
><DD
|
|
><P
|
|
> (key-combination) May be used from a terminal <A
|
|
NAME="AEN5326"
|
|
></A
|
|
>to reboot or shutdown,<A
|
|
NAME="AEN5328"
|
|
></A
|
|
> it depends on your system configuration. Note that this doesn't work from an xterminal.<A
|
|
NAME="AEN5330"
|
|
></A
|
|
>
|
|
<B
|
|
CLASS="KEYCAP"
|
|
>CTRL</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>ALT</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>DEL</B
|
|
>
|
|
<A
|
|
NAME="AEN5336"
|
|
></A
|
|
>
|
|
begins the reboot/shutdown immediately, the user does not have to be logged in.</P
|
|
><DIV
|
|
CLASS="TIP"
|
|
><BLOCKQUOTE
|
|
CLASS="TIP"
|
|
><P
|
|
><B
|
|
>You can change the behaviour of
|
|
<B
|
|
CLASS="KEYCAP"
|
|
>CTRL</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>ALT</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>DEL</B
|
|
>
|
|
<A
|
|
NAME="AEN5344"
|
|
></A
|
|
>
|
|
from rebooting: </B
|
|
>To disable
|
|
<B
|
|
CLASS="KEYCAP"
|
|
>CTRL</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>ALT</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>DEL</B
|
|
>
|
|
<A
|
|
NAME="AEN5351"
|
|
></A
|
|
>
|
|
from rebooting your computer (or to have it do something different), you can edit the /etc/inittab<A
|
|
NAME="AEN5353"
|
|
></A
|
|
> file (as root). </P
|
|
><P
|
|
>Here is how it looks on a Mandrake/Mandriva <SPAN
|
|
CLASS="PRODUCTNAME"
|
|
>Linux</SPAN
|
|
> system:
|
|
<PRE
|
|
CLASS="SCREEN"
|
|
># Trap
|
|
<B
|
|
CLASS="KEYCAP"
|
|
>CTRL</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>ALT</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>DEL</B
|
|
>
|
|
<A
|
|
NAME="AEN5362"
|
|
></A
|
|
>
|
|
ca::ctrlaltdel:/sbin/shutdown -t3 -r now </PRE
|
|
></P
|
|
><P
|
|
>Note that the # means a comment (and is not used). If you simply put a # (hash) before the command it would disable it (it would become a comment). </P
|
|
><P
|
|
>You could also change the command it runs for example if you changed the <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>-r</I
|
|
></SPAN
|
|
> to a <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>-h </I
|
|
></SPAN
|
|
>the computer would turn off instead of rebooting, or you could have it do anything you want. It's up to your creativity to make it do something interesting.</P
|
|
></BLOCKQUOTE
|
|
></DIV
|
|
></DD
|
|
></DL
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
SUMMARY="Footer navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="c4975.htm"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="book1.htm"
|
|
ACCESSKEY="H"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x5368.htm"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Controlling the system</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="c4975.htm"
|
|
ACCESSKEY="U"
|
|
>Up</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Controlling Processes</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |