How to stop the X server in Ubuntu


To stop X in a normal Ubuntu installation:
switch to a virtual terminal (Ctrl+Alt+F1), log in, and issue the following command:

sudo service lightdm stop #(if using ubuntu 11.10+)


sudo service gdm stop #(if using an older version of ubuntu)

This should stop the display manager which in turn should stop X.
To restart the dm, issue the same command but with start as an argument (replaces stop).

This has been tested with: 10.10, 10.04, and 9.10, 11.10, and mint12.

Post a comment or leave a trackback: Trackback URL.


  • Donald Livesay  On October 5, 2009 at 8:21 pm

    this does not work any longer in 9.10 and i am a nuby to ubuntu

    • Anxious Nut  On November 23, 2009 at 1:07 pm

      sudo service gdm stop” should work in ubuntu 9.10 (karmic koala). “sudo /etc/init.d/gdm stop” should also work, but ubuntu developers are asking users not to.

  • sigtermer  On October 5, 2009 at 9:14 pm

    using scripts is the best way to start/stop daemons. i haven’t tried 9.10 yet, but assuming that it’s still using gdm (probably is), you can stop the gdm by following these steps:
    1. switch to a virtual terminal. ctrl+alt+F1
    2. type: sudo killall gdm
    this should stop gdm thereby stopping x.

    do what you need to do then start gdm by typing: sudo gdm

    Just remember that there has to be a script that starts and stops gdm in ubuntu 9.10. as i mentioned, i haven’t tried it yet. but this method should work. if it doesn’t, make sure that ubuntu is using gdm and not some other display manager.

    hope that helped šŸ™‚

  • Henry  On September 6, 2010 at 1:09 pm

    That doesn’t work anymore in 9.10 + LINUX OS UBUNTU

    • sigtermer  On September 6, 2010 at 1:34 pm

      Thanks for the heads up.
      This post has been updated: you can stop gdm using service(8).

    • Luiz Carlos Querido  On October 22, 2011 at 6:33 pm

      I solved this doing killall gdm3

      • AnxiousNut  On October 23, 2011 at 12:32 pm

        No need to kill it, just do: sudo service gdm3 stop and if it tells there is no such service, they replace “gdm3” with just “gdm”.

  • rohit  On January 24, 2012 at 10:11 am

    on typing sudo service gdm stop
    I get a black screen and i need to type ctrl+alt+del to restart my machine….

    I am not able to stop my gdm service
    m trying to install ubuntu on lts 10.04 on sony vaio eh25 64 bit machine
    with nvidia geforce 410m with cuda
    It is not taking my drivers and so it is showing me maximum resolution=800 x 800 on typing xrandr in the terminal
    please help

    • seininn  On January 24, 2012 at 1:40 pm

      10.04 is an old distro, but I’ll try to help anyway I can.

      First, are you typing ‘sudo service gdm stop’ from a vertual terminal (Ctrl+Alt+F1) or a terminal emulator inside the desktop environment (gnome-terminal)?

      Make sure you switch to a virtual terminal first before writing that command.

      After switching type the following sequence:
      sudo sh -c “service gdm stop; sleep 10s; killall -9 gdm”

      wait ten seconds and you should get your prompt.

      I hope that helps.

  • Shadowfire  On February 8, 2012 at 8:59 am

    Try the following.

    int 3

  • Stelios  On June 30, 2012 at 7:23 pm

    For Ubuntu 12.0 use: sudo service lightdm stop

    • Palletje  On July 3, 2012 at 2:25 pm

      for me this doesn’t work, I do not get any confirmation that lightdm is actually stopped and still get the above error

  • simon  On July 2, 2012 at 11:30 am

    Trying this in Linux Mint 13 Mate 1.2. None of the above (gdm or lightdm) works. Any idea what to use?

  • simon  On July 2, 2012 at 11:59 am

    I’m answering myself: the correct command would be sudo service mdm stop. However, this doesn’t bring up a command line prompt (screen goes just black). A work around: -> Control Centre -> Services -> “deactivate mdm”. Then restart and you can log into your system from the command line. To then restart into graphics mode, type “init 5”.

    • seininn  On April 3, 2013 at 10:49 am

      Although a year late, Thank you for taking the time to post the solution here after finding it yourself.

      Unfortunately, I don’t have Linux Mint installed so I can’t verify the validity of this myself for its inclusion in the main article.

      Regarding the black screen, perhaps manually switching to a virtual terminal would have elevated the issue.

      Sorry for the year late response, and have a nice day.

  • pinterest decor  On March 30, 2013 at 6:46 pm

    hello to all the communityIs this ok to forward this exact article to my email list or it is not allowed

    • seininn  On April 3, 2013 at 10:36 am

      Sure! though attribution would be appreciated.

      Have a great day.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: