My xorg session is on tty1 and if I want to issue a command from tty (because I cannot do it from xorg session for some reasons), I press Ctrl+Alt+F2, for example, and type a command. But I cannot start graphical applications from any tty except first since there is no xorg session in it. Then I am curious how can I switch to tty1 where xorg session is running and back to the session?

4 Answers 4


You can switch tty as you have described by pressing:

  • Ctrl+Alt+F1 : (tty1, X is here on Ubuntu 17.10+)
  • Ctrl+Alt+F2 : (tty2)
  • Ctrl+Alt+F3 : (tty3)
  • Ctrl+Alt+F4 : (tty4)
  • Ctrl+Alt+F5 : (tty5)
  • Ctrl+Alt+F6 : (tty6)
  • Ctrl+Alt+F7 : (tty7, X is here when using Ubuntu 17.04 and below)

You might also be able to use Alt+Left/Right

Note that different distros assign these differently. RHEL 6, for example, assigns the X server to tty1 and a "dumb terminal" / "console" to tty2-7, while RHEL 5 assigns consoles to tty1-6, and x.org to tty7. Some x.org setups also make switching to any random console more difficult; RHEL 5.5, for example, has a dedicated x.org key to switch to tty1, and from there you can get to tty2-6 more easily.

Related: What is the difference between shell, console, and terminal?

  • 1
    x is on tty1 on (current) ubuntu 18.04.
    – user8162
    Commented Sep 7, 2018 at 9:54
  • 1
    doesn't work for me. I have a "60 Percent" keyboard without top row F1..12. Those get combined with the top 5th row of numbers. I have to us the Fn shifter key to access them. But it doesn't work in combination with ctrl-alt. So, I will need to find an alternative way to switch between tty consoles. And suppose I want to logout of tty3, then switch to tty7? I couldn't logout with the chvt command. I think some new keyboard layouts need to be made for Linux, for keyboards with only 5 rows of keys. They are getting popular. Folks shouldn't have to take their hands off of homerow.
    – user12711
    Commented Feb 13, 2022 at 1:18

Alternatively, you can use the chvt command -- for example, sudo chvt 1 to switch to TTY1, and sudo chvt 7 to switch back to the X session again. See here for more details.


how can I switch to tty1 where xorg session is running and back to the session?

Because X is running on tty1, but not on tty2. A tty is a "virtual terminal", meaning it is supposed to represent an actual physical screen and keyboard, etc. The terminals are all on simultaneously, but since you only have enough hardware to interface with one at a time, that's what you get.

You can in fact run multiple X sessions on different ttys and switch between them. You need a valid ~/.xinit or ~/.Xclients first. If you don't, for illustration:

echo -e "#!/bin/sh\n mwm" > ~/.xinit
chmod u+x ~/.xinit

Check first that mwm exists by trying it from the command line. As long as it doesn't say "command not found" you're good. Now from tty2 try startx.

If there isn't a display manager doing something totalitarian, you should get a plain black window with a big X mouse cursor. Left clicking should give a crude looking menu from which you can now "Quit"; but before that CtrlAltF1 will take you to the other X session on tty1 (and F2 gets you back, etc.).

  • What if I want to do it from ssh terminal? Doing startx is not possible from ssh terminal, isn't it? I need the ssh terminal to be in the same session with existing/running tty. Commented Aug 26, 2017 at 1:52
  • Set up X forwarding on the ssh server then it is possible to run X over ssh..... Commented Jul 12, 2020 at 19:21

You must set DISPLAY environment variable to :0 that means the tty1 is your display provider. and you can set it to :1 for tty2, etc.

just run below command on tty2:

export DISPLAY=:0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .