Tag Info

Hot answers tagged

76

Anyone can execute shutdown, but triggering a system shutdown requires root privileges. But shutdown is not setuid, and so only root can successfully execute it. The shutdown program is nice enough to check your privileges and let you know if there is a problem, but even if it naively tried a system shutdown, nothing would happen. GLENDOWER: I can call ...


36

Generally, one uses the shutdown command. It allows a time delay and warning message before shutdown or reboot, which is important for system administration of multiuser shell servers; it can provide the users with advance notice of the downtime. As such, the shutdown command has to be used like this to halt/switch off the computer immediately (on Linux and ...


34

You can do this directly from the shutdown command, see man shutdown: SYNOPSIS /sbin/shutdown [-akrhPHfFnc] [-t sec] time [warning message] [...] time When to shutdown. So, for example: shutdown -g 21:45 That will run shutdown -h at 21:45. For commands that don't offer this functionality, you can try one of: A. Using at The at daemon ...


28

There is no difference in them. Internally they do exactly the same thing: reboot uses the shutdown command (with the -r switch). The shutdown command used to kill all the running processes, unmount all the file systems and finally tells the kernel to issue the ACPI power command. The source can be found here. In older distros the reboot command was ...


27

It doesn't get much faster than using the System Request (SysRq) functionality and then triggering an immediate reboot. This is a key combination understood by the kernel. Enable SysRq: echo 1 > /proc/sys/kernel/sysrq Now, send it into reboot. echo b > /proc/sysrq-trigger b - Immediately reboot the system, without unmounting or syncing ...


22

The hardware power button triggers an ACPI event that acpid (the ACPI daemon) notices and reacts to; in this case by shutting down the system, although you could have it do whatever you want. The ACPI daemon runs as root, so it has permission to shutdown the system. Desktop environments (e.g. gdm for Gnome) typically run as root as well, so I suspect they ...


20

Try the following commands: Display list of last reboot entries: last reboot | less Display list of last shutdown entries: last -x | less or more precisely: last -x | grep shutdown | less You won't know who did it however. If you want to know who did it, you will need to add a bit of code which means you'll know next time. I've found this resource ...


17

It depends you started task. If it is some command line tool you could simply run halt or shutdown -h now: wget http://..../somelargefile; halt - halt will be executed after wget wget http://..../somelargefile && halt - halt will be executed if wget return no errors wget http://..../somelargefile || halt - halt will be executed if wget return ...


17

It's a bit historical. halt was used before ACPI (which today will turn off the power for you)*. It would halt the system and then print a message to the effect of "it's ok to power off now". Back then there were physical on/off switches, rather than the combo ACPI controlled power button of modern computers. poweroff, naturally will halt the system and ...


17

Linux Mint is based on Ubuntu, so I'm guesing the runlevel system is probably the same. On Ubuntu, scripts for the different runlevels are executed according to their presence in the /etc/rc[0-6].d directories. Runlevel 0 corresponds to shutdown, and 6 to reboot. Typically the script itself is stored in /etc/init.d, and then symlinks are placed in the ...


15

We don't necessarily need them both, but we have them both because of the history of Unix, and its multiplicity of versions. From their respective man pages: The shutdown utility appeared in 4.0BSD. A reboot utility appeared in Version 6 AT&T UNIX. shutdown is more general-purpose, and more powerful, while reboot is friendlier and easier to ...


15

The binary shutdown itself checks if your UID is 0. See the strace output of: strace /sbin/shutdown -r -h now ... ... geteuid() = 10001 setuid(10001) = 0 getuid() = 10001 write(2, "shutdown: Need to be root\n", 26shutdown: Need to be root ) = 26 exit_group(1) ...


12

On most Linux systems, the Ctrl+Alt+Del key sequence action is configured in either /etc/inittab or /etc/init/control-alt-delete.conf. Usually, this will reboot the system, but you could modify the command to halt the system instead. In /etc/inittab: ca::ctrlaltdel:/sbin/shutdown -t3 -h now Or /etc/init/control-alt-delete.conf: start on ...


11

Depending on your distro use the chkconfig or update-rc.d tool to enable/disable system services. On a redhat/suse/mandrake style system: sudo chkconfig apache2 off On Debian: sudo update-rc.d -f apache2 remove Checkout their man pages for more info.


11

Try Molly guard: $ sudo apt-get install molly-guard This package will prevent unintended shutdown/reboot/suspend/hibernate by interactively prompting you to enter the hostname of the system. However, it's trivial to configure molly-guard to completely disable shutdown/reboot/suspend/hibernate. Simply create an executable file at ...


11

You can suspend or hibernate your system and then automatically wake it up with rtcwake command. For example to suspend (to ram) and resume in 60 seconds do rtcwake -s 60 -m mem To hibernate (suspend to disk) in one hour from now and resume in two hours: sleep 3600; rtcwake -s 3600 -m disk You can also wakeup the system at given time with -t option ...


10

Only root privileged programs can gracefully shutdown a system. So when a system shuts down in a normal way, it is either a user with root privileges or an acpi script. In both cases you can find out by checking the logs. An acpi shutdown can be caused by power button press, overheating or low battery (laptop). I forgot the third reason, UPS software when ...


10

You can run shutdown -c to cancel an already running shutdown.


10

If you can still access a text mode console, or if you can log in remotely: You can use ps or other process listing tools and kill to try killing some processes. A few programs will save your work (at least to a recovery file) if they receive a kill -HUP or plain kill. They might not have time to do it if you go straight for rebooting. Run sudo kill ...


10

There seems to be no way to log this data to a file. For the boot process, there is the bootlogd package which creates the file /var/log/boot, but nothing for the shutdown/reboot process. As far as I can see there is no way to log with rsyslog either, and even if there was, there are messages printed after rsyslog is stopped. Part of my shutdown/reboot ...


9

If your system uses PAM, the login denial when /etc/nologin exists is triggered by the pam_nologin module. You can skip the pam_nologin invocation for users matching certain criteria with pam_succeed_if. For example, if you want to allow users in the adm group to log in on a text console even if /etc/nologin exists, add the following line to ...


9

You should be able to do this with a mains timer between the mains outlet and the power supply. Shut down the Raspberry at 4 A.M using a cron job, then set the timer to cut the mains a bit later and to restore power at 5 A.M.


8

I suspect this is somewhat dependant on which version of UNIX/Linux you are using. On Centos (and I expec other modern Linux) halt calls shutdown (providing you're not at runlevel 0 or 6) so your system will be shutdown cleanly. On Solaris 10 halt is more brutal, it just flushes the disk caches and powers off the system - no attempt is made to run any ...


8

If you are fast enough you can issue an init 2 (or whatever runlevel you want) and that will likely stop the shutdown. Anything involving killing the shutdown command will fail as the command runs too quickly I tried this with the script below and and even it's not fast enough to stop the shutdown #!/bin/bash shutdown -h now shutdown -c "Aborting ...


8

Not really (at least, to my knowledge). If you've got SystemV style init scripts, you could create something along the lines of /etc/rc6.K00scriptname and /etc/rc0.d/K00scriptname, which should get executed prior to any of the other scripts in there.


8

It depends on your Display Manager! (i.e. KDM, GDM) Please bear in mind your DM runs as root! (it needs root privileges in order to run your session process as the user you log in) When you click shutdown in KDE or GNOME, your DE sends a signal to your DM to power off or restart after the session has terminated. Then, your DE tells every program to end and ...


7

You should always use shutdown. You can add this to your ~/.bashrc file: PROMPT_COMMAND='history -a' This will append the in-memory history to your history file after each command is completed.


7

The shutdown binary will only work for the root user. The typical approach to this is to set up sudo rules to allow the user to execute shutdown as root. Assuming the user doesn't already have full sudo permissions (the first user on an Ubuntu desktop system does, for example) you might add the following line to /etc/sudoers (using the visudo utility, for ...


7

The suggested solution is to run the service unit as a normal service - have a look at the [Install] section. So everything has to be thought reverse, dependencies too. Because the shutdown order is the reverse startup order. That's why the script has to be placed in ExecStop. The following solution is working for me: [Unit] Description=... [Service] ...


7

They're not the same thing, just very closely related. In practice, unless you want to specify a particular time to shutdown or to force an immediate unclean reboot/halt/poweroff, it really doesn't matter whether you run shutdown -h or halt... or shutdown -r vs reboot. Things weren't so nicely convenient in the past, but this is the way it works now (a lot ...



Only top voted, non community-wiki answers of a minimum length are eligible