Is it possible, in latest Ubuntu distro, to launch GUI apps directly from a tty without loading window/desktop manager?

We need this in situations like: After configuring an Ubuntu system to boot into text-mode CLI, we just need to launch:

  • gedit to edit some source files.
  • evince to view some pdf files
  • firefox to quickly view some movies for short entertainment

The idea is to have an easy-enough life inside text-mode Linux with quick-and-brief access to X stuffs. We only need one GUI window each time.

  • 1
    This is much like a system administrator who wants to have some brief entertainment while maintaining a server. – user940471 Apr 2 '19 at 7:09
  • Note that we still keep the Ubuntu installation fully-fledged. No axes plz. :-) – user940471 Apr 2 '19 at 7:11
  • Where you want to launch these GUI apps? I think, you need to have loged-in desktop session to launch these apps inside. Here is one idea: askubuntu.com/a/1040852/566421 – pa4080 Apr 2 '19 at 7:42
  • after logging into text-mode, without typing startx – user940471 Apr 2 '19 at 7:54

That's easy. All you need to do is edit your .xinitrc and enable command line login.

WARNING: The following steps tell you to do "exactly" what you are asking. You will not be able to move any windows with your mouse because there won't be a window manager running. I advise you to at least have a window manager running so that you can move the windows or at least have a tiled window manager such as i3.

If you still wish to proceed despite this warning, follow these steps:

  • Install xterm: sudo apt install xterm
  • Open/Edit ~/.xinitrc and put xterm at the bottom and save the file
  • Disable GUI: sudo systemctl set-default multi-user.target
  • Restart and the system should now start in command line mode.
  • Log in and type startx and X will start with xterm running
  • Launch any program you want from there. To exit, type exit.
  • To re-enable GUI mode, type: sudo systemctl set-default graphical.target

Special note: You may need to click inside the xterm window with your left mouse button before you are able to type. Another way to exit is via pressing simultaneously Ctrl+Alt+Backspace.

  • and once you have done that, if you want X to start automatically, then create/edit .bash_login and put startx in it and now X will start right after you enter your user name + password on the command line. – marko Apr 2 '19 at 9:38

marko's solution is great. I just wanted a one off solution to run inside of a new virtual terminal without configuring defaults differently and it is as simple as logging in on a new tty and running:
startx xterm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy