344

How can I restart X Window Server from the command line?

I'd really like to be able to restart my GUI without having to do a full system reboot.

antivirtel
  • 3,685

7 Answers7

361

NOTE: This will forcefully quit all graphical programs, you'll lose any unsaved work, and you'll be logged out. Non-graphical programs will not be affected.

TL;DR: on systems with systemd (Ubuntu 15.04 and newer)

sudo systemctl restart display-manager

This will restart the appropriate display manager service (lightdm till 17.04, gdm3 after, sddm in Kubuntu, etc.). You can replace display-manager with lightdm, gdm3, sddm, etc. if needed, but this should be enough.


For other Ubuntu versions, first find which display manager your ubuntu is having with following command:

cat /etc/X11/default-display-manager

Than depending on what display manager, you can use one of the following commands:

  • Default Ubuntu (with LightDM)

    sudo systemctl restart lightdm  
    
  • Gnome (with GDM)

    sudo systemctl restart gdm
    
  • KDE (with KDM)

    sudo systemctl restart kdm
    

    Note: From 12.10 to 15.04, Kubuntu also uses LightDM.

  • For MDM (e.g. for Mint Cinnamon)

    sudo systemctl restart mdm
    
Jay Brunet
  • 1,403
txwikinger
  • 29,406
41

For 11.04 and earlier:

sudo service gdm restart

For 11.10 and later:

sudo service lightdm restart

jokerdino
  • 41,732
25

Found out that you can do sudo pkill X

and it seems to work for me!

gontadu
  • 862
14

You can try pressing Ctrl+Alt+Backspace to restart X.

10

Newest version of Ubuntu as of 24 Oct, 2012.

  1. Open Dash Home
  2. Search for keyboard layout
  3. Click Options
  4. Expand tab labelled "Key sequence to kill the X server"
  5. Enable it and Close.

Command Line:

sudo restart lightdm
Nathan
  • 109
9

Since ubuntu 9.04 Ctrl+Alt+Backspace is disabled, however you can now type Alt gr + Print Screen + K.

http://www.sudo-juice.com/ubuntu-11-10-restart-x-shortcut/

Kris Harper
  • 13,705
uboonto
  • 99
1

For KDE:

sudo systemctl restart sddm.service