FUNDAMENTALS A Complete Guide for Beginners
The shutdown command in Linux is useful for safely shutting down the system. The machine can be shut off immediately or on a schedule with a 24-hour format. It securely shuts down the system. In this article, I will describe all the features and uses of the shutdown command in Linux with multiple examples.
A. Description
Shutdown refers to stopping or shutting down a computer or service. When executing the shutdown command, all currently active users and processes are informed that the system is shutting down. New login attempts are not permitted when the shutdown is initiated. You can shut down your system immediately or schedule a specified time for shutdown.
B. Syntax
The syntax of the shutdown command in Linux is very simple and is as below:
shutdown [OPTIONS]... [TIME] [MESSAGE]
C. Options
There are many useful options available for the shutdown command. I have listed some of the most commonly used options, which are given below. You can learn more about options and their uses by checking the man page.
man shutdown
Useful Options
- -r: Asks for the system to be restarted following a shutdown.
- -h: Equivalent to halt unless power is off depending on the specified option.
- -H: Stop the operating system.
- -P: Power off the machine.
- -c: Cancel a shutdown that is currently in effect. This can be used to invoke a shutdown with a time argument other than “+0” or “now.”
- -k: Do not halt, power off or reboot, only send out the warning messages.
Practical Examples of the “shutdown” Command in Linux
The shutdown is a helpful command that shuts down the system securely. In the section below, I will show you some of the most useful applications for the shutdown command in Linux.
Example 1: Shutdown the System With the “shutdown” Command in Linux
It is the simplest form of the shutdown command, without any arguments or options. It will take about one minute to shut down the system. You can shut down your system with this command by following the steps below.
Steps to Follow >
➊ At first, open the Ubuntu Terminal.
➋ Type the following command into the command prompt:
sudo shutdown
➌ Now, press the ENTER button.
➍ Enter your user PASSWORD.
Output >
The system will take about one minute to shutdown. That means you have to wait one minute to shut down your system.
Similar Readings
- The “time” Command in Linux [4 Practical Examples]
- The “tty” Command in Linux [4 Practical Examples]
- The “uptime” Command in Linux [5 Practical Examples]
- The “vmstat” Command in Linux [6 Practical Examples]
- The “uname” Command in Linux [11 Practical Examples]
- The “apt-get” Command in Linux [10 Practical Examples]
Example 2: Shutdown the System Immediately
The shutdown command, with the time argument “0” shuts down the system immediately. Here, I will shut down the system immediately using the shutdown command. You can do the same with this command by following the steps below.
Steps to Follow >
➊ At first, open the Ubuntu Terminal.
➋ Type the following command into the command prompt:
sudo shutdown +0
OR,
sudo shutdown now
➌ Now, press the ENTER button.
➍ Enter your user PASSWORD.
Output >
When you press ENTER after typing your user PASSWORD the system will shut down immediately.
Example 3: Shutdown the System at a Specified Time
The shutdown command, with a time argument, allows you to shut down your system at a specific time, mentioned as the argument value. I’m going to schedule the shutdown at 5:00 PM. You can do the same by following the steps below.
Steps to Follow >
➊ At first, open the Ubuntu Terminal.
➋ Type the following command into the command prompt:
sudo shutdown 17:00
➌ Now, press the ENTER button.
➍ Enter your user PASSWORD.
Output >
In the following image, you can see the shutdown time has been scheduled for 05:00 PM. You would see the output as below if you followed the above-mentioned instructions.
Similar Readings
- The “free” Command in Linux [8 Practical Examples]
- The “getent” Command in Linux [11 Practical Examples]
- The “groupadd” Command in Linux [7 Practical Examples]
- The “addgroup” Command in Linux [7 Practical Examples]
- The “groups” Command in Linux [6 Practical Examples]
- The “firewall-cmd” Command in Linux [7 Practical Examples]
Example 4: Shutdown the System After a Specified Time
The shutdown command in Linux also allows you to shut down your system after a specific time, mentioned as the argument value. I am currently scheduling the shutdown time after 40 minutes. You can do the same by following the steps below.
Steps to Follow >
➊ At first, open the Ubuntu Terminal.
➋ Type the following command into the command prompt:
sudo shutdown +40
➌ Now, press the ENTER button.
➍ Enter your user PASSWORD.
Output >
In the below image, you can see that I scheduled a shutdown after 40 minutes from now. After doing the same, you will see the following message in the terminal.
Example 5: Halt the System With the “shutdown” Command in Linux
Mainly, halt means stopping CPUs, and powering off also to ensure that the power gets disconnected. You can halt your system by following the following steps.
Steps to Follow >
➊ At first, open the Ubuntu Terminal.
➋ Type the following command into the command prompt:
sudo shutdown -H
➌ Now, press the ENTER button.
➍ Enter your user PASSWORD.
Output >
After following the above steps you will receive the following notification in your system terminal.
Similar Readings
- The “groupmod” Command in Linux [5+ Practical Examples]
- The “id” Command in Linux [7+ Practical Examples]
- The “service” Command in Linux [6 Practical Examples]
- The “sestatus” Command in Linux [4 Practical Examples]
- The “passwd” Command in Linux [7 Practical Examples]
- The “finger” Command in Linux [6 Practical Examples]
Example 6: Reboot Using the “shutdown” Command in Linux
Linux allows you to reboot your system after a specific time that you decide to reboot. For this, you have to add -r options with the shutdown command. Here, I will show you an example that you can follow.
Steps to Follow >
➊ At first, open the Ubuntu Terminal.
➋ Type the following command into the command prompt:
shutdown -r +5
➌ Now, press the ENTER button.
Output >
In the following image, you can see that I set the reboot to occur after 5 minutes, hence it will start the system after a shutdown.
Similar Readings
- The “dmesg” Command in Linux [7+ Practical Examples]
- The “install” Command in Linux [6+ Practical Examples]
- The “reboot” Command in Linux [3 Practical Examples]
- The “sync” Command in Linux [8 Practical Examples]
- The “chage” Command in Linux [7 Practical Examples]
- The “env ” Command in Linux [9 Practical Examples]
Example 7: Cancel a Scheduled Shutdown
As you can schedule a shutdown time, you can also cancel the scheduled shutdown. To cancel a scheduled shutdown, you have to follow the steps below.
Steps to Follow >
➊ At first, open the Ubuntu Terminal.
➋ Type the following command into the command prompt:
shutdown -c
➌ Now, press the ENTER button.
Output >
In the following image, If you follow the time carefully, you can see that the scheduled reboot time is over but the system didn’t reboot, which means the scheduled shutdown is canceled due to the shutdown -c command.
Conclusion
In this article, I’ve shown the operation of the shutdown command. I’ve also provided some relevant examples. You should be able to use the shutdown command effectively on your own if you properly read this article and follow the above-mentioned guidelines.
Similar Readings
- The “sudo” Command in Linux [8 Practical Examples]
- The “df” Command in Linux [11 Practical Examples]
- The “apt” Command in Linux [13+ Practical Examples]
- The “top” Command in Linux [8 Practical Examples]
- The “htop” Command in Linux [7 Practical Examples]
- The “enable” Command in Linux [6 Practical Examples]