How do I kill the x-server?

Every time I try to kill the x-server,

sudo service lightdm stop

so that I can install the latest Nvidia drivers, I get an error message.

stop: Unknown instance:

What am I doing wrong?


Solution 1:

  1. Use ctrl+alt+F1 to switch to terminal,
  2. login
  3. run sudo service lightdm stop, lightdm and xserver should be stopped now (check with ctrl+alt+F7, which is your current xorg session, it should not show any desktop now)
  4. do your things
  5. run sudo service lightdm start to start lightdm and xorg again.

Good Luck!

Solution 2:

I did a little more digging around and found that I could just use pgrep to find its PID and then kill it.

pgrep dm -l

sudo kill (insert PID here)

Solution 3:

Try running sudo service gdm stop.

The reason your command may be resulting in that output is because lightdm isn't your Display Manager.

In addition to gdm, also try xdm and kdm.

Solution 4:

You will need the help of htop or top. Write down the PID number of the process you want to kill (in this case, Xorg). Once you have the PID, run the below command in a root shell (sudo -s):

kill -9 <PID>

For example:

kill -9 1234

You should then be able to install the NVidia drivers.