Linux – Kill xserver from command line (init 3/5 does not work)

command lineinitkilllinuxx-server

I'm running Linux Mint 10, although I've had this same issue with other variants of Linux. I've been told/found while researching that if the X server hangs or otherwise errors, one can drop to a root prompt, usually at another tty, and execute init 3 (to drop to single user mode) and then init 5 to return to the default, graphical session.

Needless to say, I've tried this before in multiple configurations on multiple machines to no avail. The only feedback I receive form executing those two commands is a listing of VMWare services (from a kernel module) that are stopped and then restarted.

Note: If I run startx (either before or after init 3), then I am told that the xserver is still running and that I should remove /tmp/.X0-lock. Having tried that, it removes that error message, but claims that the xserver cannot be attached as another instance is running.

How do I kill the xserver completely? Can I killall some process name?

Best Answer

Linux Mint is based on Debian. In Debian, the single user run level is 1; 3 is still a multi-user run level and as such allows X to continue execution. So, you need to switch to run level 1, init 1, to stop all processes initiated by the default run level (2). Then you can re-init to the proper run level: init 2.

See Debian run levels for more information.