This tutorial intends to teach you to Shutdown or Reboot your Linux Operating System via the Command Line Interface (CLI).
“Shutdown” refers to the process of stopping and shutting down a computer or server. This involves cutting the power to the main components of the system using a controlled process. Applications are closed, active processes and protocols are saved to the hard drive, device drivers are removed, and user settings are saved in the process. Linux operating systems can easily be stopped, shut down, and restarted using the command line interface.
Steps To Shutdown Linux Via Command Line
To complete this guide, you need to log in to your server as a root or non-root user with sudo privileges. Then, follow the steps below to see how you can shutdown your Linux server in different ways.
shutdown Command in Linux
The shutdown command brings the system down in a secure way. All logged-in users are notified that the system is going down, and login operations are blocked. It is possible to shut the system down immediately, or after a specified delay.
You can start by using the following command:
You will get the following output:
Output Shutdown scheduled for Thu 2023-02-16 04:34:15 EST, use 'shutdown -c' to cancel.
The message tells you that your system is scheduled to shut down after one minute.
To stop this, you can use the following command:
If you want to shutdown your system immediately, you can use the following command:
Also, you can shutdown your Linux system at a specific time. To do this, you can use the following syntax:
For example, to shutdown the system in 20 minutes, you can use the command below:
Also, you can use a message in front of your scheduled time.
shutdown time "message"
shutdown 20 "if you want to cancel the process type shutdown -c"
To see more options, you can use the command below:
Output shutdown [OPTIONS...] [TIME] [WALL...] Shut down the system. Options: --help Show this help -H --halt Halt the machine -P --poweroff Power-off the machine -r --reboot Reboot the machine -h Equivalent to --poweroff, overridden by --halt -k Don't halt/power-off/reboot, just send warnings --no-wall Don't send wall message before halt/power-off/reboot -c Cancel a pending shutdown --show Show pending shutdown See the shutdown(8) man page for details.
halt / fasthalt Command in Linux
The halt command writes data to the disk and then stops the processor. The machine does not restart. Only a root user can run this command. Do not use this command if other users are logged in to the system. If no other users are logged in, the halt command can be used. Use the halt command if you are not going to restart the machine immediately. When the message
....Halt completed.... is displayed, you can turn off the power.
The halt command logs the shutdown by using the syslogd command and places a record of the shutdown in /var/adm/wtmp, the login accounting file. The system also writes an entry into the error log that states that the system was shut down.
The fasthalt command stops the system by calling the halt command. The fasthalt command provides BSD compatibility.
To power off the system, you can use the following command:
If you don’t use -p option then the command stops the CPU process at once instead of stopping them gracefully.
Examples of halt command:
# halt #halt the machine # halt -p #poweroff the machine # halt --reboot #reboot the machine
poweroff Command in Linux
poweroff sends an ACPI signal which instructs the system to power down
The following are examples of poweroff commands:
# poweroff #poweroff the machine # poweroff --halt #halt the machine # poweroff --reboot #reboot the machine
Reboot command in Linux
reboot instructs the system to restart. These are the examples of this command:
# reboot #reboot the machine # reboot --halt #halt the machine # reboot -p #poweroff the machine
At this point, you have learned to Shutdown or Reboot your Linux Operating System via the Command Line Interface (CLI).
Hope you enjoy it. You may be like these articles on the Orcacore website:
Unable To Connect to cqlsh Cassandra
XAMPP Unable To Determine IP Address of hostname