the shutdown command in Linux With Example
shutdown command in linux

the shutdown command in Linux With Example

As you know Linux and Linux distribution is operated by the terminal and GUI. but mostly Linux operating works on the command line. Commands are used to execute any kind of process in Linux. In this article, we will discuss the Linux shutdown command. With the help of the Linux shutdown command, you can shut down the Linux system in a very safe way. when executing the shutdown command in the terminal, the system and server can be shut down immediately or can also be shut down by giving a schedule. At the time of system shutdown, all processes are stopped and the logged user is automatically logged out, from the system. the shutdown command is a super administrative command that can be run only by the root user or must have the root privilege

Syntax of shutdown Command

shutdown [OPTIONS] [TIME] [MESSAGE]

Know other options related to the shutdown

If you want to read more theory and Linux shutdown-related options, then you must visit the man page or run the man help command in the Linux terminal. man file is similar to a manual document for all Linux files, settings, and commands

#man shutdown
linux shutdown command

If you want to read the Brief Manual information related shutdown command in Linux, you can run the –help command instead of the man help command.

Also Read: What Is Linux Help Comand

#shutdown --help
help Command in linux

standard system Shutdown Command

linux shutdown command

If you are not logged into the system as the root user, you will need to type sudo before the shutdown command and the system will shut down immediately after entering the correct sudo privilege user account password.

You can also use the -h option to shut down the system, this will give you the same result as the shutdown command

Shut Down the System at a Specific Time

If you want to shut down the system at a specific given time, then you have to use some option after the command which can be seen below the screen. As you can see below that I have given the system shutdown time at 11:15 am, you can set this time according to your need.

#shutdown hh:mm
#shutdown  11:15

Shut Down the System at a Specific Time

If you want to shut down the system after a few minutes Or hours, that means you want to schedule the system to shut down at a future given time, for that, you have to set a time after the shutdown command at which time you want to shut down the system. For example, you can look at the below screenshot.

Shut Down the System at a Specific Time

Shutdown the system immediately

If you want to shut down the system or server immediately without any alerts and messages, then for this you have to use the Now option and then the single space after the shutdown command. To shut down the system immediately, run the following command on the terminal.

# shutdown now

Before Shutdown the system sends Broadcast a Message to all connected system

With the help of the below command, you can shut down the system at a given time and also deliver a broadcast message to all the connected users of the system so that all the connected users of the system can stop the work and properly save their work. This type of command is mostly used to inform the user before troubleshooting and during debugging the system.

As can be seen in the below screenshot we have scheduled the system to shut down after +15 minutes and also broadcast a message “the System will shut down within 15 minutes so please save your work” to all connected users. You can set the time and message according to your needs.

#shutdown [time] "[message]"
#shutdown +15 "System will shutdown within 15 minutes so please save your work"
Shutdown the system and Broadcast a Message

Reboot the system with the shutdown command

To reboot the system with the help of the shutdown command, type -r after the shutdown command.

As already discussed, we can send a broadcast message to each connected client before shutting down the system, Similarly, you can reboot the system at a given time and broadcast the message to all the users connected to the system as mentioned in the below screen.

#shutdown -r +15 "System will Reboot after 15 minutes so please save your work"

Cancel a scheduled shutdown and Reboot Command in Linux

If you have run the system shutdown or reboot schedule command and want to cancel it for some reason, then you have to press the CTRL + C key from the keyboard or run the shutdown -c command in the Linux terminal.

#shutdown -c
Reboot the system and Broadcast a Message

Shutdown system with Init command

when you are executing the init 0 commands in the Linux terminal means you are changing the system run level as you know run level 0 is a system shutdown command and run level 6 (init 6) is a system reboot command.

# init 0
Init command in linux

Shutdown system with Halt Command

The halt command prompts the system Hardware to stop all functions of the CPU. In this process, the system remains on but no process works in the system, this command is used when you do some system maintenance-related work.

# halt

If you want to reboot the system with the help of the halt command, then type –reboot after the halt command, and the system will shut down immediately.

#halt --reboot
halt  command in linux

Use Power off Command

With the help of the poweroff command, you can stop, shut down and reboot the system. Some examples of the poweroff commands can be seen below the screen.

#poweroff               #poweroff  your the machine  
#poweroff --halt        #halt the ystem
#poweroff --reboot     # reboot the system

In this article, we have learned about Linux shutdown, reboot and schedule shutdown, and reboot commands, and hope that got you good knowledge full information about Linux. Comment below for any kind of feedback.

Rate this post
simi kaithal