Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The command for restarting Gnome2 is:

sudo /etc/init.d/gdm restart

What is the equivalent for Unity?

share|improve this question

7 Answers 7

up vote 17 down vote accepted

Gdm is still used to manage the desktop sessions, but the Upstart way is

sudo service gdm restart.

Update: Another option, which isn't using the terminal but using a key combination, can be found at How to set keyboard combination to kill the server?

share|improve this answer
    
I found this very practical and functional way, thank you. –  rjbgbo May 1 '11 at 12:50

The command unity can be used to restart unity. It restarts the window manager, so your open programs will stay intact and you will not be logged out.

If you run the command from a terminal app, you should add & disown to detach it from the terminal. If you don't, then the unity program will become a child process of the terminal app such that when you close the terminal, unity will also close.

It might also be worthwhile to add &> /dev/null (before the disown bit) so that text and error output does not clutter your terminal.

So, the command is:

unity &> /dev/null & disown

If you can't open the terminal application due to the desktop being extremely unresponsive (or any other reason), you can open a purely text-based terminal by hitting alt-ctrl-F1 through F6.

There you will get a text terminal, you have to login first.

Then you can run the command above, then hit alt-ctrl-F7 or alt-ctrl-F8 to come back to the graphical desktop.

This tends to fix "hanging" problems.

As a side note: since Unity is a compiz plugin, you can restart unity by restarting compiz using the command:

compiz --replace

If you run it from the alt-ctrl-F1 terminal, you will need a --display parameter

compiz --display :0 --replace

You'll still need to add & disown

share|improve this answer
    
Thanks. I think this one is better than the accepted one because it only restarts Unity, not the whole display server. Thanks! –  kroq-gar78 Mar 8 '13 at 23:41
    
wow! I've been using Ubuntu for 4 years (maybe not that much, but still...) and wasn't aware of the existence of & disown. Thank you! –  FRD Apr 15 '13 at 3:46
    
And another point for Linux over Windows. Restarting your crashed UI without loosing anything: Check! –  Christoph Grimmer-Dietrich May 15 '13 at 8:16
    
Just a minor thing. If you are using any shell other than bash (I use fish), use nohup instead if disown. nohup goes at the begining of the command, like this: nohup compiz --display :0 --replace & –  Daniel Rodriguez May 27 '13 at 2:12

You don't need to open a tty. In most cases Alt-F2 still works. Just enter "unity". That's it. No & disown needed.

share|improve this answer

In Ubuntu 13.04 you can use the following:

sudo service lightdm restart
share|improve this answer

The command to restart GDM is sudo stop gdm followed by sudo start gdm, and should be done from a tty.

If you are trying to restart unity itself just run unity (but remember you need to do this from the run dialog.

share|improve this answer
1  
+1 for the unity command –  hasenj Apr 30 '11 at 21:16

In a terminal, run nohup compiz --replace. The nohup command will make sure compiz isn't closed when you close the terminal.

share|improve this answer

I like to change GNOME's font size attribute depending on the monitor. I've been shutting down the programs directly so the window position is saved. I put this in the script which probably does pretty much the same thing:

    nautilus -q && sleep 2 && bgcmd nautilus -n
    pkill unity-panel
    pkill unity-window
    sleep 1
    unity-window-decorator &> /dev/null & disown
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.