Ubuntu – Switching between console and GUI in ubuntu

command lineguilightdmtty

When in GUI mode, is there a CLI commands that kills the GUI and drops me into the console?

When in CLI mode, is there a CLI command that drops me into the GUI?

I found startx, but this drop me into the GUI without the unity interface, how do I launch anything?

I found service lightdm start which drops me into the GUI with the unity interface.

I found service lightdm stop which drops me into a blank black screen with no CLI input capability.

I found the Ctl + Alt + F* sends me back between console and GUI, but it does not kill the GUI. I want to kill the GUI if I don't want to use it anymore.

Best Answer

  • To go in tty1 and stop the GUI, run from terminal:

    sudo xdotool key Ctrl+Alt+F1 && sudo service lightdm stop

    You can test now in the tty1 the fact that the GUI is stopped using:

    sudo service lightdm status

    Note: xdotool is not installed by default in Ubuntu, so you must to install it first using sudo apt-get install xdotool command.

    To start the GUI again from tty1, you can run (as you said):

    sudo service lightdm start

    If you want also to close (exit) tty1 session, you can use:

    sudo service lightdm start && logout