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

Meet the 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 comments… add one
  • David Taté Feb 22, 2008, 8:14 pm

    thank you

  • Rizme Sep 3, 2008, 3:05 am

    thank you. very usefull shell commands

  • rishie Dec 14, 2008, 8:34 pm

    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.

  • HImadri Nayak Aug 10, 2009, 3:10 am

    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?

  • mech Oct 17, 2009, 4:44 pm

    Thank for the commands.

  • Brian Oct 29, 2009, 6:10 am

    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:

  • poswer Nov 5, 2009, 7:51 am

    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

  • Demba Sonko Nov 6, 2009, 10:03 pm

    Thanks for all efforts

  • Joseph Thornton Jan 9, 2010, 7:17 pm

    Thanks for sharing these commands with us.

  • João Rodrigues Jan 27, 2010, 3:17 pm

    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

  • Gana Mar 13, 2010, 6:22 am

    thank you

  • Mahesh Mar 13, 2010, 3:01 pm

    very very thank you……..

  • Atif Apr 17, 2010, 8:04 am

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

  • arif May 2, 2010, 1:12 am

    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.

  • Khizar Jun 14, 2010, 1:09 am

    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?

  • chetan Dec 11, 2010, 5:44 pm

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

  • dizar Dec 24, 2010, 2:24 am

    chetan December 11, 2010 at 5:44 pm

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

    sudo shutdown -c

  • indra pd Dec 24, 2010, 3:07 am

    thanks boss

  • Ian Jan 3, 2011, 11:05 pm

    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

  • Ian Jan 3, 2011, 11:07 pm

    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

  • ehsan Feb 16, 2011, 1:21 pm

    Thanks, very usefull

  • gonkyouka Mar 17, 2011, 7:10 pm

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

  • Joost Apr 1, 2011, 12:40 pm

    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.

  • Joost Apr 1, 2011, 12:44 pm

    there is more: I prefer runlevel switching:

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

  • Andre Jan 28, 2012, 8:49 am

    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.

  • van Apr 3, 2012, 2:49 pm

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

  • Sheldon May 11, 2012, 7:02 am

    Thanks pal..

  • nikhl Aug 4, 2012, 12:02 pm

    how to remote restart computer using ubuntu terminal ???

  • Vibhav Sinha Nov 14, 2012, 5:09 pm

    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?

  • Lucho Jan 16, 2014, 10:39 pm

    Thanks a lot! I really need that basic commands.

Leave a Comment