halt command
halt
shutdown the system instantly
It instructs the hardware to stop all CPU functions but leaves it powered on.
- -p power-off the machine
- –reboot reboot the machine
shutdown [OPTION] [TIME] [MESSAGE]
shutdown -h now
reboot command
For graceful shutdown and restart of the machine.
reboot
- -p poweroff
- -f Reboot forcibly
- –halt halt the machine
- –verbose Outputs slightly more verbose messages, useful for debugging problems with shutdown.
Reboot in next 15 minutes
shutdown -r +15
Reboot Now
shutdown -r now
The Kernel loads the /sbin/reboot and /sbin/shutdown binaries from the disk and execute them. If it fails due to a problem with the drive, generates an error like:
reboot
bash: /sbin/reboot: Input/output error
shutdown -r now
bash: /sbin/shutdown: Input/output error
On the next boot, an fsck would correct whatever is wrong with the disk.
poweroff command
Sends an ACPI signal which instructs the system to power down.
poweroff
–halt halt the machine
–reboot reboot the machine
Suspend & Hibernate Command
Suspend & Hibernate
pm-suspend-hybrid
Suspends Systems
pm-suspend
Hibernate System
pm-hibernate
init command
Init with run level 6 is set for rebooting
init 6
OR
/sbin/init 6
init 0 shutdown the Linux System
Reboot logs
/var/log/wtmp
contains records all logins and logouts.
Use the command to parse this file
last reboot
Disable Shutdown and Reboot for specific users or group
vi /etc/sudoers
Add these lines to the Command Aliases section.
Cmnd_Alias SHUTDOWN = /sbin/shutdown,/sbin/reboot,/sbin/halt,/sbin/poweroff # User privilege specification scpl ALL=(ALL:ALL) ALL, !SHUTDOWN # Allow members of group sudo to execute any command %developers ALL=(ALL:ALL) ALL, !SHUTDOWN
Another way is to remove execution permissions on shutdown and reboot commands for all users except root.
chmod o-x /sbin/shutdown
chmod o-x /sbin/reboot
chmod o-x /bin/systemctl
Seldom Reboot on Servers Satisfying Linux System Administrators
Linux 4.0 enabled servers like Oracle Linux, and RHEL can go without reboot for years with Ksplice.
Red Hat kpatch and SUSE kGraft, provides the Linux to keep running even while critical patches installed.
Kpatch issues a stop_machine() command and looks at the stack of existing processes using ftrace to patch safely. Further, it redirects the running code to the patched functions and then removes the now outdated code.