Terminal or shell command to shutdown or reboot Ubuntu Linux

So how do you shutdown or reboot the Ubuntu Linux server from a terminal or a shell prompt? If GUI is working you can always click on a shutdown button. If GUI is not working or if you are working remotely over ssh type the following commands to shutdown from a terminal:

How do I restart /shutdown from a terminal?

To shutdown / poweroff Ubuntu Linux type any one of the following command:
sudo halt
OR
sudo shutdown -h now

To reboot Ubuntu Linux

Type the command to restart Ubuntu box from the command line:
sudo reboot

More information can be found about these two commands by typing following commands (man page):
man reboot
man shutdown

Author: admin

I like chocolate, gadgets, open source software, photography, traveling and all shades of green colors. I love spending time with fun loving friends and family members. This is my own online journal.

30 thoughts on “Terminal or shell command to shutdown or reboot Ubuntu Linux”

  1. What would be the shell command to get the shutdown/restart popup? The reason why I am asking is because I want to change the command on one of the applets on AWM from logout to shutdown/restart. I would rarely if ever use the logout feature since I am the sole user of my computer.

  2. I have a dual booting machine having XP SP2 and UBUNTU 8.04. I have installed UBUNTU under XP. Now using secured Shell from an remote PC I want to logout from ubuntu such that it would not go to the dual boot screen where Windos XP is the firs option and I have no control over it from remote PC to stop the machine to to go to Windows. This is only possible if I use logout not restart or reboot. So, please tell me how is it possible from terminal?

  3. Was just browsing and saw this. I have a dual boot as well. and wanted to control the same problem when booting.

    what I did was write a script that edits the grub configuration file. the file is in /boot/grub. I have 9.10 and the file is called grub.cfg, but in older versions it is called menu.lst.

    you are looking for a line that says “default x” where x is the default row that grub starts on. starting from 0(in 9.10 this is “default = x”). soooooo…

    i run my script and it goes and finds that line and changes it so that instead of being “default = 0” which will turn my computer on with ubuntu as the default system, it now says “default = 6” because windows is the 7th item on my grub menu. at the end of my script i put ‘shutdown -r now’ which reboots the computer.

    note, this script has to be run with root permission to edit the file(and in ubuntu 9.10 the permissions have to be adjusted on the file to allow root to write to it).

    What I did was attach this script to an launcher on my taskbar so whenever I click it it runs “gksu scriptname” note also that gksu must be used with the launcher because no terminal will appear for you to enter the root password if you just use “sude” here.

    here it is written in perl, this should work on 8.04 without any changes assuming things are configured normally. just change the numbers “0” and “6” accordingly for your system.

    here:

  4. i am using ubuntu 8.04 LTS amd 64 os some i try to shutdown my box halt -p shutdown or poweroff not able to shutdown still system is running so after i shutdown manually can you give sol what is problem.

    thanks

  5. There is already a command that does basically the same thing: grub-reboot.

    You can do
    grub-reboot 0
    to instruct the system to reboot, and set grub menu entry 0 (the first) as the system to boot next. Substitute 0 for 1, 2, etc to reboot some other entry. The command must be run by root and will ask for confirmation, but you can pipe an answer into it.

    João

  6. I’m using ubuntu 8.04 LTS with squid proxy server its working fine after restarting through terminal window
    Thank you for useful commands

  7. hi,

    i need to have LAMP with php 5.2.9 to match my wamp developed php scripts on windows xp.

    will any one be knd enough to show me exactly how i can install/compile/upgrade to php 5.2.9 on my ubuntu server.

    thanks.

  8. Hi,

    Is there any way of changing windows settings through ubuntu. The last thing I did before XP would keep restarting, is that I went into msconfig and checked the /safeboot box.

    Thanks!

    Also, what is the root username for ubuntu?

  9. chetan December 11, 2010 at 5:44 pm

    hi,,how to cancel an existing shutdown operation and create a new one???

    sudo shutdown -c

  10. Google “xampp”
    It is a lampp stack for both Linux and Windows, so you would have the same versions in both.
    Current version of PHP is 5.3.1, but older versions are available

  11. At the risk of starting a flame war, there is no “root” account (as such) for Ubuntu.
    Run “sudo -s” and input your own password to get a root shell

  12. Thank you so much for this website. I am looking for a shutdown command but I end up reading your article about coral. :D

  13. There is a root but it is by default disabled, it is very simple to enable it:
    sudo -i
    will give you a rootshell,
    you want to login as root, then use the “passwd” command in this shell it will ask for a new root password without asking the old root password,
    now you can log in as root in any shell (eg:CTRL+ALT+F1-6) but not in graphic shell.

  14. there is more: I prefer runlevel switching:

    sudo init 6
    = reboot
    sudo init 0
    = halt
    sudo init 1
    = boot into single user mode

  15. you can also use

    shutdown -ry 10

    10 is 10 minutes, you can change it if you need to shutdown programs first.
    you can also put this in a sh script.

  16. i want someone to help me ………..how to shutdown another linux computer through my own wire……………..without the other person notice

  17. Thanks! Is there any way to set ubuntu to start after few hours(given time). That is I want my server to be shutdown for three hours. How to set this?

Leave a Reply to Mahesh

Your email address will not be published. Required fields are marked *