The command for restarting Gnome2 is:
sudo /etc/init.d/gdm restart
What is the equivalent for Unity?
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
& disown
. Thank you!
nohup compiz --display :0 --replace &
May 27, 2013 at 2:12
unity-2d-shell &> /dev/null & disown
The Upstart way is
sudo service lightdm restart
for newer versions using lightdm
or sudo service gdm restart
for older versions using gdm.
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 X server?
gdm
does not seem to be available in Ubuntu 14.04.
Jan 14, 2015 at 12:37
nohup compiz --display :0 --replace &
seems to restart unity without losing your current session's windows. See askubuntu.com/a/38597/35666
You don't need to open a tty. In most cases Alt-F2 still works. Just enter "unity". That's it. No & disown needed.
unity
from the panel worked
In a terminal, run nohup compiz --replace. The nohup command will make sure compiz isn't closed when you close the terminal.
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.
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