The Shutdown process in a Linux system is an intelligent chain process where in the system ensures the dependent process have successfully terminated.
TL;DR:
Difference between the Halt and Poweroff in Linux?
What is a Cold Shutdown and Warm Shutdown?
Linux System System Halt
: The Halt process instructs the hardware to Stop the functioning of the CPU. Can be referred as a Warm Shutdown.
Linux System Poweroff/Shutdown
: The Poweroff function sends the ACPI(Advanced Configuration and Power Interface) to power down the system. Can be referred as a Cold Shutdown.
As you may be aware the Linux runtime environment is a duo combination of processes running in User space and the Kernel space, All the major system activities and resources are initiated and governed and terminated by Kernel space.
So we got the Kernel space and the User space, The kernel space is where all the reseurce related processes run, which follows a finite behaviour, and the the userspace where the processes are dependent on the user actions, most of the userspace programs depend on the kernel space and make a context switch to get the CPU scheduling and such..
So, In the sequence of Shutdown on a linux machine, the userspace processes are first terminated in a systematic fashion through the scripts triggered by the core systemd processes which ensures clean exit and termination all the processes.
The Linux system provides us quite a few commands to enforce fast shutdown or a graceful shutdown of the operating system, each having their own consequences.
Firstly the init
or the systemd
which is the pid 1
process is what controls the runlevel of the system and it determines which processes are launched and running in that runlevel
The init
is a powerful command which executes the runlevel it is told to.
Here the init 0
proceeds to Power-off the machine
$ sudo init 0
Here the init 6
proceeds to Reboot the machine
$ sudo init 6
These commands are real quick as it triggers the kernel space shutdown invocation process.. most often resulting in unclean termination of processes resulting system recovery and journaling while booting.
The following commands Shutdown the machine in seconds after issuing the command But tend to follow the kill sequence and clean exit of the processed.
$ sudo shutdown $ sudo poweroff $ sudo systemctl poweroff
Prints a wall message to all users.
All the processes are killed and the volumes are unmounted or converted to be in Read-Only mode while system power off is in progress.
Puts the system into a complete poweroff mode cutting out power supply to the machine completely.
$ sudo halt $ sudo systemctl halt
Prints a message of “System halted” and Puts the machine in halt mode
If the --force
or -f
when specified twice the operation is immediately executed without terminating any processes or unmounting any file systems and resulting in data loss
The servers can only be brought back online through physical poweron or Remote Power manager console such as IPMI or ILOM.
To reboot or [/code]systemctl kexec[/code] will to restart the operating system which is one power cycle or equivalent of shutdown followed by the startup.
$ sudo reboot $ sudo systemctl kexec $ sudo systemctl reboot
If the --force
or -f
when specified twice the operation is immediately executed without terminating any processes or unmounting any file systems and resulting in data loss
It is important to understand that the commands are all softlinks to systemctl shutdown command. and ensure in proper shutdown sequence process
[vamshi@linuxcent cp-command]$ ls -l /usr/sbin/halt lrwxrwxrwx. 1 root root 16 Jan 13 14:41 /usr/sbin/halt -> ../bin/systemctl [vamshi@linuxcent cp-command]$ ls -l /usr/sbin/reboot lrwxrwxrwx. 1 root root 16 Jan 13 14:41 /usr/sbin/reboot -> ../bin/systemctl [vamshi@linuxcent cp-command]$ ls -l /usr/sbin/poweroff lrwxrwxrwx. 1 root root 16 Jan 13 14:41 /usr/sbin/poweroff -> ../bin/systemctl
It is important to observe that all the commands are softlink to the systemctl process, When issuing a shutdown or reboot
The best practice to poweroff the system by enabling broadcast the notification message to all the users connected actively either through the Pseudo remote connection terminal or TTY terminals, Demonstrated as follows:
$ sudo systemctl poweroff
# this writes an entry into the journal, the wtmp and broadcasts the shutdown message to all the users connected through PTS and TTY terminals
What is the difference between systemctl poweroff and systemctl halt ?
The Linux System when put to a Halt state, stops the all the applications and ensures they’re safely exited, filesystems and volumes are unmounted and it is taken into a halted state where in the power connection is still active. And Can only be brought online with a power reset effectively with a simple reset.
The Halt
process instructs the hardware to Stop the functioning of the CPU.
Commonly can be referred as a Warm Shutdown
.
Below is the screenshot to demonstrate the same
The Poweroff
function sends the ACPI
(Advanced Configuration and Power Interface) to power down the system.
The Linux System when put to a Poweroff state it becomes completely offline following the systematical clean termination of processes.. and power input is cut off to the external peripherals, which is also sometimes called as cold shutdown, and the startup cold start.
Commonly can be referred to as a Cold Shutdown
.
If you found the article worth your time, Please share your inputs in the comments section and share your experiences with shutdown and reboot issues
Can I reboot Linux remotely?
How to shutdown the remote Linux server. You must pass the -t option to the ssh command to force pseudo-terminal allocation. The shutdown accepts -h option i.e. Linux is powered/halted at the specified time.
Can you reboot a server remotely?
Open command prompt, and type “shutdown /m \\RemoteServerName /r /c “Comments”“. … Another command to restart or shutdown the Server remotely is Shutdown /i. Type Shutdown /i on the command prompt and it will open another dialogue box.
What is the Linux command to reboot?
To reboot Linux using the command line:
- To reboot the Linux system from a terminal session, sign in or “su”/”sudo” to the “root” account.
- Then type “ sudo reboot ” to reboot the box.
- Wait for some time and the Linux server will reboot itself.
How do I reboot from remote desktop?
Procedure. Use the Restart Desktop command. Select Options > Restart Desktop from the menu bar. Right-click the remote desktop icon and select Restart Desktop.
What does sudo reboot do?
sudo is short for “Super-user Do”. It has no effect on the command itself (this being reboot ), it merely causes it to run as the super-user rather than as you. It is used to do things that you might not otherwise have permission to do, but doesn’t change what gets done.
How do I remotely turn on a Linux server?
Enter the BIOS of your server machine and enable the wake on lan/wake on network feature. …
Boot your Ubuntu and run “sudo ethtool -s eth0 wol g” assuming eth0 is your network card. …
run also “sudo ifconfig” and annotate the MAC address of the network card as it is required later to wake the PC.
How do I restart a terminal server remotely?
From the remote computer’s Start menu, select Run, and run a command line with optional switches to shut down the computer:
To shut down, enter: shutdown.
To reboot, enter: shutdown –r.
To log off, enter: shutdown –l
How do I send Ctrl Alt Del to remote desktop?
Press the “CTRL,” “ALT” and “END” keys at the same time while you are viewing the Remote Desktop window. This command executes the traditional CTRL+ALT+DEL command on the remote computer instead of on your local computer.
How do I remotely restart a server by IP address?
Type “shutdown -m \ [IP Address] -r -f” (without quotes) at the command prompt, where “[IP Address]” is the IP of the computer you want to restart. For example, if the computer you want to restart is located at 192.168. 0.34, type “shutdown -m \ 192.168.
How do I reboot from command prompt?
- From an open command prompt window:
- type shutdown, followed by the option you wish to execute.
- To shut down your computer, type shutdown /s.
- To restart your computer, type shutdown /r.
- To log off your computer type shutdown /l.
- For a complete list of options type shutdown /?
- After typing your chosen option, press Enter.
How does Linux reboot work?
The reboot command is used to restart a computer without turning the power off and then back on. If reboot is used when the system is not in runlevel 0 or 6 (i.e., the system is operating normally), then it invokes the shutdown command with its -r (i.e., reboot) option.