Shutting down a Debian system
From NewbieDOC
--Chris Lale 13:13, 10 February 2007 (CET)
Contents |
1 Introduction
Pressing the RESET button is the equivalent of pulling the plug - you are risking file corruption. Here are some safer ways to shut down your system. Adapted from posts in a thread on the Debian-user list (http://lists.debian.org/debian-user/2007/02/msg01393.html). As with so much in GNU/Linux, there is more than one solution.
2 Shutting down from a console screen
You can use these methods even without being logged in.
2.1 Shutting down a local machine
If you are used to another operating system, you may know about the Ctrl-Alt-Del key combination. You must first switch to a virtual console (text only screen) before you can use this method for shutting down Debian.
Switch to one of the six virtual consoles (Ctrl-Alt-F1, Ctrl-Alt-F2, ..., Ctrl-Alt-F6) by holding down the Ctrl and Alt keys and tapping one of the function keys "F1" - "F6". At the console screen, issue the reboot key combination Ctrl-Alt-Del (ie hold down the "Ctrl" and "Alt" keys, and tap the "Del" or "Delete" key).
Ctrl-Alt-F1 Ctrl-Alt-Del
Wait until the system shuts down and the restart begins,then power down the system. You can power down safely anytime before Grub begins to boot the system.

Alternatively, if you wish Grub to boot automatically but wish to be able to prevent the system from booting, change the delay from 5 seconds (which is much too
short) to 10 or 15 seconds.2.2 Shutting down an unresponsive local machine
If a machine is really not responsive (which happens once in a while) you can try these three key combinations in sequence : Alt+SysRq+S, Alt+SysRq+U and Alt+SysRq+O. They synchronise the discs ("S"), unmount the discs ("U") and turn the system off ("O"). It is important that you issue all three commands in the correct order so that you avoid data corruption.
Alt+SysRq+S SysRq: Emergency Sync Emergency Sync complete Alt+SysRq+U SysRq: Emergency Remount R/O Emergency Remount R/O complete Alt+SysRq+O SysRq: Power off Shutdown
This will minimize the chance of data loss but isn't a long term solution.
If you wish to reboot the system rather than shutting down, use Alt+SysRq+B instead of Alt+SysRq+O.
Alt+SysRq+B Resetting
You can find out more about key combinations at http://linux.about.com/od/linux101/l/blnewbie5_1.htm .
3 Shutting down from a shell prompt
If you are logged in to a console you can shut the system down from the shell prompt. You can also use this method from a desktop environment by first obtaining a shell prompt by running a "Terminal" application.
3.1 Shutting down a local machine
At the prompt, switch user ("su") to user root (see also the talk/discussion page).
$ su (enter root's password) #
The standard way to shut down is to enter
# shutdown -h now
An alternative is to enter
# halt The System is going down for halt now!
If you include the "-p" switch, the system will also poweroff.
# halt -p
If you wish to reboot rather than shutting down, use the "-r" switch instead.
# shutdown -r now
An alternative is to enter
# reboot
3.2 Shutting down a remote machine
If your machine is in a network and Debian has booted, you can access the machine by SSH from another machine in the network. Log in as user root via SSH, and shut it down using one of the "shutdown" commands (see .html#Shutting down from a shell prompt). This works even if the remote keyboard or screen have locked up.
4 Shutting down from a GUI environment
4.1 Shutting down from the login screen
After X starts, but before you have logged in, you should be presented with a graphical login screen. This is provided by the display manager. The default display manager is the Gnome Display Manager ("gdm"). There is an "Actions" menu with a "Shut down the computer" item. You can use this without logging in and without needing a password.
4.2 Shutting down from the Gnome desktop
Once logged into Gnome, you should find "Shut Down" in the "Desktop" menu in the top panel.

4.3 Shutting down from the KDE desktop
Once logged into KDE, you can right click with the mouse pointer over the "desktop" (background), which produces a menu with a number of options, the one you want being "Log out user" (where user is replaced by your login name). This will bring up another window with four selections. "End Current Session" just logs you out, the next two will power down or reboot.
5 Modify the action of the POWER button
Provided your machine is ACPI compliant, install the package "acpid". It contains a script /etc/acpi/powerbtn.sh and a symbolic link to that (/etc/acpi/events/powerbutton). With that you can just hit the power button of your machine and your system will gracefully do a shutdown to halt and then power off.
Content is available under GNU Free Documentation License 1.2, unless otherwise stated.