Custom Search

How to power off Ubuntu server with Linux shutdown command

The Linux shutdown command has several options that you can use to bring down the Linux system. In the previous post, we've seen how to reboot Ubuntu server with shutdown command. In this post,  we are going to use the Linux shutdown command again. This time is to power off the Ubuntu server.

There are several options available with shutdown command that can be used to power off Linux system. One example is -h option, which means to halt the system after it has been brought down. We can add other things such as a comment message when invoking shutdown -h command. As you can see from the example of Ubuntu restart post before, we have to specify a time argument after the shutdown option so the system know when to shutdown the system. Here are some examples on how to power off Ubuntu server using shutdown command with other things that you can do:

1) Using Linux shutdown command with -h option example:

luzar@ubuntu:~$ sudo shutdown -h now
[sudo] password for luzar:

Broadcast message from luzar@ubuntu
        (/dev/pts/0) at 11:32 ...

The system is going down for halt NOW!

The example above show a basic shutdown command used to power off Ubuntu server. We used '-h' option and a time argument 'now' which means to bring down the system after we press enter.

 2) Using Linux shutdown command -p option example:

luzar@ubuntu:~$ sudo shutdown -h -P +1

Broadcast message from luzar@ubuntu
        (/dev/pts/0) at 11:47 ...

The system is going down for power off IN ONE MINUTE! 

The example above shows the '-P' option is added after the '-h' option. The -P option means 'power off'. When -P is used after -h option, it means we tell the system to power off after the system halt. Also this time we used +1 in the time argument. That means we want to bring down the system after 1 minute.

3) If you have to warn all your users, you can write a message after the time argument. See the example below:

luzar@ubuntu:~$ sudo shutdown -h -P +3 Please save your work now!

Broadcast message from luzar@ubuntu
        (/dev/pts/0) at 11:57 ...

The system is going down for power off in 3 minutes!
Please save your work now!
shutdown: Shutdown cancelled

If you want to cancel shutdown after invoked the command, you can press Ctrl+C combination keys. That will work if you do not use the 'now' time argument. If you just want to warn users to log out and prevent other user to login without actually bring the system down, you can use '-k' option.

luzar@ubuntu:~$ sudo shutdown -k +3 Please save your work now!

Broadcast message from luzar@ubuntu
        (/dev/pts/0) at 12:11 ...

The system is going down for maintenance in 3 minutes!
Please save your work now!
luzar@ubuntu:~$

That's all.

6 comments:

  1. thx

    but i want to cancel the shutdown i tested ctrl+c
    but didn't work

    ReplyDelete
  2. Cancelling the shutdown using ctrl+c only works if you provide time argument, such as example no.2 and no.3.

    If you use the 'now' time argument like the command below,

    sudo shutdown -h now

    the ctrl+c wouldn't works.

    ReplyDelete
  3. I have tried that and ubuntu halts but not poweroff. Any ideas?

    ReplyDelete
  4. When Ubuntu halt, push the power button to switch off. You can try 'init 0' command to see if it works.

    ReplyDelete
  5. i have 2 system both is same configuration and same os like ubuntu 8.04.1 LTS i shutdown a machine like halt -p first system was shutdown perfectlly there is no power. but 2'nd system i was gave command halt -p it was showing the messange "system is going down for power off now" still power is there can u help me.

    ReplyDelete
  6. You can try searching solutions regarding the computer you are using. Some older machines need to be switch off manually. Also some laptops do not power off after given the shutdown command. You need to tweak something. This kind of problem is normal when installing Linux in the past. Try google by specifying the computer you are using, such as "Sony vaio fail to power off". Good luck!

    ReplyDelete

Please keep comment relevant and strictly no spam will be tolerated. Thank you.