How to Shutdown your Linux System using Command Line - The Tech Influences

1
The recommend and secure way to shutdown Linux Machine and server is to use the shutdown command. Another option is to use of Poweroff command, today this page explain how to shutdown Linux based system using command line

How to Shutdown your Linux System using Command Line

To Shutdown Linux using the Command Line

Method 1:- Using Init Command:- 

  • To shut down the Linux system first open the terminal
  • Then type “sudo init 0” command in terminal
  • Now your system will be shutdown automatically after type this command
Here you can see the example for better understanding

Example:-
[root@redhat-1 ~]# sudo init 0

Remote side unexpectedly closed network connection

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Session stopped
    - Press <Return> to exit tab
    - Press R to restart session
    - Press S to save terminal output to file

Method 2:- Using Poweroff Command:-

  • To shut down the Linux system first open the terminal
  • Then type “poweroff” command in terminal
  • Now your system will be shutdown automatically after type this command
Here you can see the example for better understanding

Example:-
[root@redhat-1 ~]# poweroff

Remote side unexpectedly closed network connection

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Session stopped
    - Press <Return> to exit tab
    - Press R to restart session
    - Press S to save terminal output to file

Method 3:- Using systemctl poweroff command:-

  • To shut down the Linux system first open the terminal
  • Then type “systemctl poweroff” command in terminal
  • Now your system will be shutdown automatically after type this command
Here you can see the example for better understanding

Example:- 
[root@redhat-1 ~]# systemctl poweroff
[root@redhat-1 ~]#
Remote side unexpectedly closed network connection

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Session stopped
    - Press <Return> to exit tab
    - Press R to restart session
    - Press S to save terminal output to file

Method 4:- Using shutdown –h now command:-

  • To shut down the Linux system first open the terminal
  • Then type “shutdown –h now” command in terminal
  • Now your system will be shutdown automatically after type this command
Here you can see the example for better understanding

Example:-
[root@redhat-1 ~]# shutdown -h now

Remote side unexpectedly closed network connection

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Session stopped
    - Press <Return> to exit tab
    - Press R to restart session
    - Press S to save terminal output to file

Method 5:- Using shutdown –h +0 command:-

  • To shut down the Linux system first open the terminal
  • Then type “shutdown –h  +0” command in terminal
  • Now your system will be shutdown automatically after type this command
Here you can see the example for better understanding

Example:-
[root@redhat-1 ~]# shutdown -h +0
Shutdown scheduled for Mon 2023-07-10 22:08:59 IST, use 'shutdown -c' to cancel.
[root@redhat-1 ~]#
Remote side unexpectedly closed network connection

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Session stopped
    - Press <Return> to exit tab
    - Press R to restart session
    - Press S to save terminal output to file


Reboot Linux System command Syntax

The Syntax is:-

  • sudo /sbin/shutdown -h time "Message"
  • shutdown -h time "message"
Where ,
  • h – Power off the system
  • Time – when to shut down, you can power off  immediately or after 2 minutes. The word now is an alias for 0+
  • Massage – send warning message to send to all users 
Here you can see the example for better understanding


Example1:-1-  ROOT USER (Here we will send the request to all the client for system shutdown)
[root@redhat-1 ~]# sudo /sbin/shutdown -h 05 "Development server is going down for maintenance. Please save your work ASAP."
Shutdown scheduled for Mon 2023-07-10 22:15:48 IST, use 'shutdown -c' to cancel.
[root@redhat-1 ~]# date
Monday 10 July 2023 10:14:53 PM IST
[root@redhat-1 ~]# date
Monday 10 July 2023 10:15:41 PM IST
[root@redhat-1 ~]# date
Monday 10 July 2023 10:15:48 PM IST
[root@redhat-1 ~]#
Remote side unexpectedly closed network connection

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Session stopped
    - Press <Return> to exit tab
    - Press R to restart session
    - Press S to save terminal output to file
Here the system will shutdown after 5 minutes


Example1:-2-  CLIENT MACHINE (Here request will be received from ROOT User for System Shutdown)
[root@redhat-1 ~]#
Broadcast message from root@redhat-1 on pts/0 (Sat 2023-07-15 12:58:40 IST):

Development server is going down for maintenance. Please save your work ASAP.
The system is going down for poweroff at Sat 2023-07-15 13:03:40 IST!





Example2:-1-  ROOT USER (Here we will send the request to all the client for system shutdown)
[root@redhat-1 ~]# shutdown -h 05 "Development server is going down for maintenance. Please save your work ASAP."
Shutdown scheduled for Mon 2023-07-10 22:15:48 IST, use 'shutdown -c' to cancel.
[root@redhat-1 ~]# date
Monday 10 July 2023 10:14:53 PM IST
[root@redhat-1 ~]# date
Monday 10 July 2023 10:15:41 PM IST
[root@redhat-1 ~]# date
Monday 10 July 2023 10:15:48 PM IST
[root@redhat-1 ~]#
Remote side unexpectedly closed network connection

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Session stopped
    - Press <Return> to exit tab
    - Press R to restart session
    - Press S to save terminal output to file
Here the system will shutdown after 5 minutes


Example2:-2-  CLIENT MACHINE (Here request will be received from ROOT User for System Shutdown)
[root@redhat-1 ~]#
Broadcast message from root@redhat-1 on pts/0 (Sat 2023-07-15 12:58:40 IST):

Development server is going down for maintenance. Please save your work ASAP.
The system is going down for poweroff at Sat 2023-07-15 13:03:40 IST!



See the status of reboot and shutdown command

Last –x shutdown- 

Here you will see the history of shutdown that when your system has been shutdown

Sample output:-
[root@redhat-1 ~]# last -x shutdown
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 22:18 - 22:19  (00:00)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 22:15 - 22:16  (00:00)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 22:13 - 22:13  (00:00)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 22:08 - 22:10  (00:01)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 22:08 - 22:08  (00:00)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 22:07 - 22:07  (00:00)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 22:05 - 22:06  (00:01)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 22:05 - 22:05  (00:00)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 21:46 - 21:46  (00:00)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 21:45 - 21:45  (00:00)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 15:31 - 16:00  (00:28)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 14:47 - 15:23  (00:36)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 14:21 - 14:22  (00:00)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 14:17 - 14:17  (00:00)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 14:15 - 14:15  (00:00)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 13:53 - 14:10  (00:16)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 13:47 - 13:48  (00:00)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 13:46 - 13:47  (00:00)
shutdown system down  5.14.0-162.6.1.e Mon Jul 10 13:41 - 13:43  (00:01)
shutdown system down  5.14.0-162.6.1.e Sun Jul  9 23:38 - 13:28  (13:50)
shutdown system down  5.14.0-162.6.1.e Sat Jul  8 22:43 - 22:44  (00:00)
shutdown system down  5.14.0-162.6.1.e Fri Jul  7 22:18 - 01:35  (03:16)
shutdown system down  5.14.0-162.6.1.e Thu Jul  6 18:14 - 10:44  (16:30)
shutdown system down  5.14.0-162.6.1.e Tue Jul  4 14:02 - 11:12 (1+21:09)
shutdown system down  5.14.0-162.6.1.e Sat Jul  1 18:00 - 21:47  (03:47)
shutdown system down  5.14.0-162.6.1.e Sat Jul  1 17:01 - 17:02  (00:00)
shutdown system down  5.14.0-162.6.1.e Sat Jul  1 16:01 - 16:01  (00:00)
shutdown system down  5.14.0-162.6.1.e Sat Jul  1 01:11 - 10:19  (09:08)
shutdown system down  5.14.0-162.6.1.e Fri Jun 30 23:06 - 23:06  (00:00)
shutdown system down  5.14.0-162.6.1.e Fri Jun 30 22:52 - 22:53  (00:00)
shutdown system down  5.14.0-162.6.1.e Thu Jun 29 23:24 - 23:24  (00:00)
shutdown system down  5.14.0-162.6.1.e Thu Jun 29 21:54 - 21:54  (00:00)
shutdown system down  5.14.0-162.6.1.e Wed Jun 28 23:28 - 21:20  (21:52)
shutdown system down  5.14.0-162.6.1.e Wed Jun 28 20:59 - 20:59  (00:00)
shutdown system down  5.14.0-162.6.1.e Wed Jun 28 01:34 - 14:59  (13:24)
shutdown system down  5.14.0-162.6.1.e Mon Jun 26 17:43 - 17:41  (23:57)
shutdown system down  5.14.0-162.6.1.e Mon Jun 26 12:57 - 17:32  (04:34)
shutdown system down  5.14.0-162.6.1.e Sun Jun 25 12:39 - 08:52  (20:12)
shutdown system down  5.14.0-162.6.1.e Sat Jun 24 23:48 - 11:22  (11:34)
shutdown system down  5.14.0-162.6.1.e Sat Jun 24 23:40 - 23:40  (00:00)
shutdown system down  5.14.0-162.6.1.e Sat Jun 24 22:33 - 22:34  (00:00)
shutdown system down  5.14.0-162.6.1.e Sat Jun 24 22:30 - 22:31  (00:00)
shutdown system down  5.14.0-162.6.1.e Sat Jun 24 17:25 - 22:27  (05:02)
shutdown system down  5.14.0-162.6.1.e Thu Jun 22 15:09 - 16:41 (2+01:32)
shutdown system down  5.14.0-162.6.1.e Tue Jun 20 16:38 - 14:21  (21:42)
shutdown system down  5.14.0-162.6.1.e Sat Jun 17 22:51 - 11:46 (1+12:54)
shutdown system down  5.14.0-162.6.1.e Wed Jun 14 17:31 - 12:03 (2+18:32)
shutdown system down  5.14.0-162.6.1.e Tue Jun 13 20:01 - 11:32  (15:30)
shutdown system down  5.14.0-162.6.1.e Fri Jun  9 16:42 - 11:04 (2+18:22)
shutdown system down  5.14.0-162.6.1.e Sat Jun  3 18:01 - 13:02 (1+19:01)
shutdown system down  5.14.0-162.6.1.e Fri Jun  2 17:47 - 10:44  (16:56)
shutdown system down  5.14.0-162.6.1.e Fri May 26 18:18 - 11:42 (2+17:24)
shutdown system down  5.14.0-162.6.1.e Mon May 22 12:46 - 12:18 (2+23:31)
shutdown system down  5.14.0-162.6.1.e Sat May 20 12:44 - 10:18 (1+21:33)
shutdown system down  5.14.0-162.6.1.e Thu May 18 15:04 - 15:05  (00:00)
shutdown system down  5.14.0-162.6.1.e Thu May 18 15:02 - 15:02  (00:00)
shutdown system down  5.14.0-162.6.1.e Thu May 18 14:59 - 15:00  (00:00)
shutdown system down  5.14.0-162.6.1.e Thu May 18 14:54 - 14:54  (00:00)
shutdown system down  5.14.0-162.6.1.e Wed May 10 17:47 - 12:59 (7+19:11)
shutdown system down  5.14.0-162.6.1.e Sat May  6 17:37 - 13:19 (2+19:42)
shutdown system down  5.14.0-162.6.1.e Wed May  3 11:59 - 12:00  (00:00)
shutdown system down  5.14.0-162.6.1.e Tue May  2 10:47 - 10:47  (00:00)
shutdown system down  5.14.0-162.6.1.e Sun Apr 30 12:49 - 10:27 (1+21:38)
shutdown system down  5.14.0-162.6.1.e Sun Apr 30 12:48 - 12:48  (00:00)
shutdown system down  5.14.0-162.6.1.e Thu Apr 27 12:00 - 12:00  (00:00)
shutdown system down  5.14.0-162.6.1.e Mon Apr 24 18:01 - 11:28  (17:26)
shutdown system down  5.14.0-162.6.1.e Sat Apr 22 20:03 - 10:34 (1+14:30)
shutdown system down  5.14.0-162.6.1.e Thu Apr 20 17:38 - 21:58  (04:19)

wtmp begins Thu Apr 20 16:37:19 2023
[root@redhat-1 ~]#

Last reboot- 

Here you will see the history of shutdown that when your system has been rebooted

Sample output:-
[root@redhat-1 ~]# last reboot
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 22:19   still running
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 22:16 - 22:18  (00:01)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 22:13 - 22:15  (00:02)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 22:10 - 22:13  (00:02)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 22:08 - 22:08  (00:00)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 22:07 - 22:08  (00:00)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 22:06 - 22:07  (00:00)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 22:05 - 22:05  (00:00)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 21:46 - 22:05  (00:18)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 21:45 - 21:46  (00:00)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 16:00 - 21:45  (05:45)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 15:23 - 15:31  (00:07)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 14:22 - 14:47  (00:25)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 14:17 - 14:21  (00:04)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 14:15 - 14:17  (00:01)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 14:10 - 14:15  (00:05)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 13:48 - 13:53  (00:05)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 13:47 - 13:47  (00:00)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 13:43 - 13:46  (00:03)
reboot   system boot  5.14.0-162.6.1.e Mon Jul 10 13:28 - 13:41  (00:13)
reboot   system boot  5.14.0-162.6.1.e Sat Jul  8 22:44 - 23:38 (1+00:54)
reboot   system boot  5.14.0-162.6.1.e Sat Jul  8 01:35 - 22:43  (21:08)
reboot   system boot  5.14.0-162.6.1.e Fri Jul  7 10:44 - 22:18  (11:34)
reboot   system boot  5.14.0-162.6.1.e Thu Jul  6 11:12 - 18:14  (07:01)
reboot   system boot  5.14.0-162.6.1.e Sat Jul  1 21:47 - 14:02 (2+16:15)
reboot   system boot  5.14.0-162.6.1.e Sat Jul  1 17:02 - 18:00  (00:58)
reboot   system boot  5.14.0-162.6.1.e Sat Jul  1 16:01 - 17:01  (01:00)
reboot   system boot  5.14.0-162.6.1.e Sat Jul  1 10:19 - 16:01  (05:41)
reboot   system boot  5.14.0-162.6.1.e Fri Jun 30 23:06 - 01:11  (02:04)
reboot   system boot  5.14.0-162.6.1.e Fri Jun 30 22:53 - 23:06  (00:13)
reboot   system boot  5.14.0-162.6.1.e Fri Jun 30 20:35 - 22:52  (02:17)
reboot   system boot  5.14.0-162.6.1.e Thu Jun 29 23:24 - 22:52  (23:28)
reboot   system boot  5.14.0-162.6.1.e Thu Jun 29 21:54 - 23:24  (01:29)
reboot   system boot  5.14.0-162.6.1.e Thu Jun 29 21:20 - 21:54  (00:33)
reboot   system boot  5.14.0-162.6.1.e Wed Jun 28 20:59 - 23:28  (02:29)
reboot   system boot  5.14.0-162.6.1.e Wed Jun 28 14:59 - 20:59  (05:59)
reboot   system boot  5.14.0-162.6.1.e Tue Jun 27 17:41 - 01:34  (07:53)
reboot   system boot  5.14.0-162.6.1.e Mon Jun 26 17:32 - 17:43  (00:11)
reboot   system boot  5.14.0-162.6.1.e Mon Jun 26 08:52 - 12:57  (04:05)
reboot   system boot  5.14.0-162.6.1.e Sun Jun 25 11:22 - 12:39  (01:16)
reboot   system boot  5.14.0-162.6.1.e Sat Jun 24 23:40 - 23:48  (00:08)
reboot   system boot  5.14.0-162.6.1.e Sat Jun 24 22:34 - 23:40  (01:05)
reboot   system boot  5.14.0-162.6.1.e Sat Jun 24 22:31 - 22:33  (00:02)
reboot   system boot  5.14.0-162.6.1.e Sat Jun 24 22:27 - 22:30  (00:02)
reboot   system boot  5.14.0-162.6.1.e Sat Jun 24 16:41 - 17:25  (00:43)
reboot   system boot  5.14.0-162.6.1.e Wed Jun 21 14:21 - 15:09 (1+00:48)
reboot   system boot  5.14.0-162.6.1.e Mon Jun 19 11:46 - 16:38 (1+04:52)
reboot   system boot  5.14.0-162.6.1.e Sat Jun 17 12:03 - 22:51  (10:48)
reboot   system boot  5.14.0-162.6.1.e Wed Jun 14 11:32 - 17:31  (05:59)
reboot   system boot  5.14.0-162.6.1.e Mon Jun 12 11:04 - 20:01 (1+08:56)
reboot   system boot  5.14.0-162.6.1.e Fri Jun  9 10:10 - 16:42  (06:31)
reboot   system boot  5.14.0-162.6.1.e Mon Jun  5 13:02 - 16:42 (4+03:39)
reboot   system boot  5.14.0-162.6.1.e Sat Jun  3 10:44 - 18:01  (07:17)
reboot   system boot  5.14.0-162.6.1.e Mon May 29 11:42 - 17:47 (4+06:04)
reboot   system boot  5.14.0-162.6.1.e Thu May 25 12:18 - 18:18 (1+06:00)
reboot   system boot  5.14.0-162.6.1.e Mon May 22 10:18 - 12:46  (02:28)
reboot   system boot  5.14.0-162.6.1.e Thu May 18 15:05 - 12:44 (1+21:39)
reboot   system boot  5.14.0-162.6.1.e Thu May 18 15:02 - 15:04  (00:02)
reboot   system boot  5.14.0-162.6.1.e Thu May 18 15:00 - 15:02  (00:02)
reboot   system boot  5.14.0-162.6.1.e Thu May 18 14:54 - 14:59  (00:05)
reboot   system boot  5.14.0-162.6.1.e Thu May 18 12:59 - 14:54  (01:55)
reboot   system boot  5.14.0-162.6.1.e Tue May  9 13:19 - 17:47 (1+04:27)
reboot   system boot  5.14.0-162.6.1.e Wed May  3 12:00 - 17:37 (3+05:37)
reboot   system boot  5.14.0-162.6.1.e Tue May  2 10:47 - 11:59 (1+01:12)
reboot   system boot  5.14.0-162.6.1.e Tue May  2 10:27 - 10:47  (00:19)
reboot   system boot  5.14.0-162.6.1.e Sun Apr 30 12:48 - 12:49  (00:00)
reboot   system boot  5.14.0-162.6.1.e Thu Apr 27 12:00 - 12:48 (3+00:47)
reboot   system boot  5.14.0-162.6.1.e Tue Apr 25 11:28 - 12:00 (2+00:31)
reboot   system boot  5.14.0-162.6.1.e Mon Apr 24 10:34 - 18:01  (07:27)
reboot   system boot  5.14.0-162.6.1.e Thu Apr 20 21:58 - 20:03 (1+22:05)
reboot   system boot  5.14.0-162.6.1.e Thu Apr 20 16:37 - 17:38  (01:01)

wtmp begins Thu Apr 20 16:37:19 2023
[root@redhat-1 ~]#

Used of shutdown –c command:-

  • To shut down the Linux system first open the terminal
  • Then type “shutdown –c” command in terminal
  • If you have set the shutdown time here, it will be canceled
Here you can see the example for better understanding

Example:- First I will set a timer of 1 minute in shutdown command and then cancel it
[root@redhat-1 ~]# date
Monday 10 July 2023 10:30:43 PM IST
[root@redhat-1 ~]# shutdown -h 01
Shutdown scheduled for Mon 2023-07-10 22:31:47 IST, use 'shutdown -c' to cancel.
[root@redhat-1 ~]# date
Monday 10 July 2023 10:30:51 PM IST
[root@redhat-1 ~]# shutdown -c
[root@redhat-1 ~]#
[root@redhat-1 ~]# date
Monday 10 July 2023 10:31:11 PM IST
[root@redhat-1 ~]#
[root@redhat-1 ~]# date
Monday 10 July 2023 10:31:49 PM IST
[root@redhat-1 ~]# date
Monday 10 July 2023 10:31:54 PM IST
[root@redhat-1 ~]#


Post a Comment

1Comments
Post a Comment