Linux administrator performing many tasks in their routine work. The system Shutdown and Reboot task also included in that.It’s one of the risky task for them because some times it wont come back due to some reasons and they need to spend more time on it to troubleshoot. Show These task can be performed through CLI in Linux. Most of the time Linux administrator prefer to perform these kind of tasks via CLI because they are familiar on this. There are few commands are available in Linux to perform these tasks and user needs to choose appropriate command to perform the task based on the requirement. All these commands has their own feature and allow Linux admin to use it. Suggested Read : When the system is initiated for Shutdown or Reboot. It will be notified to all logged-in users and processes. Also, it wont allow any new logins if the time argument is used. I would suggest you to double check before you perform this action because you need to follow few prerequisites to make sure everything is fine. Those steps are listed below.
This task can be performed using following commands.
Method-1: How to Shutdown and Reboot the Linux system using Shutdown Commandshutdown command used to power-off or reboot a Linux remote machine or local host. It’s offering The general syntax is # shutdown [OPTION] [TIME] [MESSAGE]Run the below command to shutdown a Linux machine immediately. It will kill all the processes immediately and will shutdown the system. # shutdown -h now
Alternatively we can use the shutdown command with halt option to bring down the machine immediately. # shutdown --halt now or # shutdown -H now
Alternatively we can use the shutdown command with poweroff option to bring down the machine immediately. # shutdown --poweroff now or # shutdown -P now
Run the below command to shutdown a Linux machine immediately. It will kill all the processes immediately and will shutdown the system. # shutdown -h now
If you run the below commands without time parameter, it will wait for a minute then execute the given command. All other logged in users can see a broadcast message in their terminal like below. [[email protected] ~]$ Broadcast message from [email protected] (Mon 2018-10-08 06:41:31 EDT): The system is going down for power-off at Mon 2018-10-08 06:42:31 EDT!for Halt option. # shutdown -H Shutdown scheduled for Mon 2018-10-08 06:37:53 EDT, use 'shutdown -c' to cancel. [email protected]# Broadcast message from [email protected] (Mon 2018-10-08 06:36:53 EDT): The system is going down for system halt at Mon 2018-10-08 06:37:53 EDT!for Poweroff option. # shutdown -P Shutdown scheduled for Mon 2018-10-08 06:40:07 EDT, use 'shutdown -c' to cancel. [email protected]# Broadcast message from [email protected] (Mon 2018-10-08 06:39:07 EDT): The system is going down for power-off at Mon 2018-10-08 06:40:07 EDT!This can be cancelled by hitting shutdown -c option on your terminal. # shutdown -c Broadcast message from [email protected] (Mon 2018-10-08 06:39:09 EDT): The system shutdown has been cancelled at Mon 2018-10-08 06:40:09 EDT!All other logged in users can see a broadcast message in their terminal like below. [[email protected] ~]$ Broadcast message from [email protected] (Mon 2018-10-08 06:41:35 EDT): The system shutdown has been cancelled at Mon 2018-10-08 06:42:35 EDT!Add a time parameter, if you want to perform shutdown or reboot in N seconds. Here you can add broadcast a custom message to logged-in users. In this example, we are rebooting the machine in another 5 minutes. # shutdown -r +5 "To activate the latest Kernel" Shutdown scheduled for Mon 2018-10-08 07:13:16 EDT, use 'shutdown -c' to cancel. [[email protected] ~]# Broadcast message from [email protected] (Mon 2018-10-08 07:08:16 EDT): To activate the latest Kernel The system is going down for reboot at Mon 2018-10-08 07:13:16 EDT!Run the below command to reboot a Linux machine immediately. It will kill all the processes immediately and will reboot the system. # shutdown -r now
Method-2: How to Shutdown and Reboot the Linux system using reboot Commandreboot command used to power-off or reboot a Linux remote machine or local host. Reboot command comes with two useful options. It will perform a graceful shutdown and restart of the machine (This is similar to your restart option which is available in your system menu). Run “reboot’ command without any option to reboot Linux machine. # rebootRun the “reboot” command with -p option to power-off or shutdown the Linux machine. # reboot -p
Run the “reboot” command with -f option to forcefully reboot the Linux machine (This is similar to pressing the power button on the CPU). # reboot -f
Method-3: How to Shutdown and Reboot the Linux system using init Commandinit (short for initialization) is the first process started during booting of the computer system. It will check the /etc/inittab file to decide the Linux run level. Also, allow users to perform shutdown and reboot the Linux machine. There are seven runlevels exist, from zero to six. Suggested Read :
Run the below init command to shutdown the system .
Run the below init command to reboot the system . # init 6
Method-4: How to Shutdown the Linux system using halt Commandhalt command used to power-off or shutdown a Linux remote machine or local host. Method-5:How to Shutdown the Linux system using poweroff Commandpoweroff command used to power-off or shutdown a Linux remote machine or local host. Poweroff is exactly like halt, but it also turns off the unit itself (lights and everything on a PC). It sends an ACPI command to the board, then to the PSU, to cut the power. # poweroffMethod-6: How to Shutdown and Reboot the Linux system using systemctl CommandSystemd is a new init system and system manager which was implemented/adapted into all the major Linux distributions over the traditional SysV init systems. systemd is compatible with SysV and LSB init scripts. It can work as a drop-in replacement for sysvinit system. systemd is the first process get started by kernel and holding PID 1. Suggested
Read : It’s a parent process for everything and Fedora 15 is the first distribution which was adapted systemd instead of upstart. systemctl is command line utility and primary tool to manage the systemd daemons/services such as (start, restart, stop, enable, disable, reload & status). systemd uses .service files Instead of bash scripts (SysVinit uses). systemd sorts all daemons into their own Linux cgroups and you can see the system hierarchy by exploring /cgroup/systemd file. # systemctl halt # systemctl poweroff # systemctl reboot # systemctl suspend # systemctl hibernateWhat is the Linux command for shutdown?To shutdown Linux using the command line: To shutdown the Linux system open a terminal application. Then type “ sudo shutdown -n now ” to shutdown the box.
Which of the following command can be used to shutdown the system?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.
What command should be used to cancel a shutdown Linux?To cancel a shutdown, use the -c (cancel) option. Although you don't get any notification that your shutdown has been canceled, your logged in users do get notified. If you don't provide a time string a shutdown will be scheduled for one minute from now.
|