Excuse me for the question, but what is the command to exit from X?
If it’s enabled, CTRL-ALT-BACKSPACE.
If not, then you have to go to a console window using eg: CTRL-ALT-F1, log in and then kill it using the kill command.
Gotta expand on the answer a bit, to make it cleaner:
From a console (using CTRL ALT F1), run: sudo systemctl stop gdm
This will stop the GDM display manager and everything it has spawned, including any X11 or Wayland sessions you might be running.
Get GUI services back by starting it again.
If you want to turn it off on boot, you can run: systemctl set-default multi-user.target
Or turn it back on by default: systemctl set-default graphical.target
graphical.target == mutl-user system plus GDM or relevant display manager for GUI
multi-user.target == “normal” Linux system without the GUI stuff
Hope this helps!
First, the F1 does usually show a GUI. The consoles are more likely to be found with F2, F3, … F6.
It is possible to run
sudo systemctl isolate multi-user.target
That stops all the services that multi-user.target does not require. That is, switches from whatever target you are at now (usually the graphical.target) to multi-user.target. Likewise, one can switch back (restart GUI) to graphical with systemctl isolate graphical.target
However, what does “exit from X” really mean?
- If it does mean “quit a GUI session”, then the GUI Desktop Environment should offer a “Logout” option. On Gnome that is from top right corner, under “power something” button (where are also Shutdown and Restart)
- If it means to kill the X11 Window Manager when it is somewhat frozen (i.e. cannot Logout), then the Ctrl-Alt-Backspace, although that option has been disabled for some versions now
- If it means switch to text-based console (while the GUI remains running), then it is the Ctrl-Alt-F_n_ shortcut
- If it means stopping the GUI, then the
systemctl isolate multi-user.target(when you have logged out from GUI session and have switched to console)
Wow, what amazing answers… I wish other sites had forums with these kind of responses… wow!
When you say “X”, do you mean that you are manually starting an X11 (X, Xorg, X Window System, but never X Windows) desktop with a command such as xinit or startx?
If so, then the last client you launch from your ~/.xinitrc will end the X session when it exits. If you have no ~/.xinitrc, then this will be an xterm.
It’s very rare for folks to run desktops this way these days and almost all unix platforms offer a variety of desktop environments - GNOME, KDE, XFCE, etc. - with desktop session launched from a graphical login manager such as gdm. Each of these will have command(s) which can cause the running session to exit, though they may need to be run in that session. To tell you the command, we’d need to know what desktop environment you’re using.
GNOME, for example, include the gnome-session-quit command. See gnome-session-quit(1)*.
In these cases “X” or Wayland (and Xwayland) is incidental.
*[This is a manual page in section 1 of the manual. Run man man to learn about the manual.]
When I did this it turned everything off and it froze on booting screen. I’m on Ubuntu
I would suggest you ask on the Ubuntu forums - this is not an Ubuntu forum, this is for Rocky Linux.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.