54

I'm unable to return to the GUI with Ctrl+Alt+F7 (or any of the 12 function keys). I have some unsaved work and I don't want to lose them. Are there any other key combinations that will allow me to switch back?

Here is what I did:

  1. I pressed Ctrl+Alt+F1 and it showed a text-based login screen as usual
  2. Then I pressed Ctrl+Alt+F7 and it showed a screen full of text (I can't remember what they were)
  3. Then I pressed Ctrl+Alt+F8 and it showed log messages that resembles /var/log/messages. Some entries are from automount, some from sendmail, and none are errors.
  4. Pressing any of the Ctrl+Alt+Fn combinations now has no effect. The cap-lock and num-lock LED no longer respond to their corresponding keys. I can use the mouse to highlight the text on the screen, but nothing else.

Any idea what happened?

I can still login to the system via SSH. GUI applications that I was using (e.g. opera) are still running and consuming tiny amounts of CPU as usual, as reported by top. Is it possible to switch back to the GUI via the command line? If possible, I don't want to restart X, because doing so will kill all the GUI applications.

System info:

 Red Hat Enterprise Linux Client release 5.7
 Linux 2.6.18-238.12.1.el5 SMP x86_64
 gnome-desktop: 2.16.0-1.fc6
 xorg-x11-server-Xorg: 1.1.1-48.76.el5_7.5

Thanks to Shawn I was able to get back using chvt 9.

Further experiments shows that if I go to the 8th virtual terminal (either by Ctrl+Alt+F8 or chvt 8), I will not be able to switch to any other terminals using Ctrl+Alt+Fx keys. Now sure if this is a bug.

3
  • 1
    On a Raspberry Pi 2 Model B (what I am using): After you hit Ctrl+Alt+F1, it brought you to the command line. On mine, you can it Ctrl+Alt+F2 and it will take you to the Pi login. Just login and after that type startx, then you will be taken back to the desktop :)
    – user114432
    May 7, 2015 at 2:48
  • 1
    @user114432 In no system I've ever used has startx returned to an existing X session. It always starts a new session on a new console (or the same console, depending on the distro). And AFAIK there is no way to translocate a running client from one X session to another. Mar 11, 2017 at 7:25
  • "...if I go to the 8th virtual terminal (either by Ctrl-Alt-F8 or chvt 8), I will not be able to switch to any other terminals using Ctrl-Alt-Fx keys." Not sure why chvt 8 would do this. But if you keep the Ctrl+Alt keys held down, after you get back into the graphical mode (aka. the GUI / X server), and press another F1-F12 function key, it will not work. You have to first release the Ctrl+Alt keys, and try again, to get out of the graphical mode. I assume this is because the graphical mode doesn't recognise that the keys were pushed down because it wasn't activated at that point in time?
    – Ben J
    May 28, 2019 at 3:58

6 Answers 6

52

chvt allows you to change your virtual terminal.

From man chvt:

The command chvt N makes /dev/ttyN the foreground terminal. (The corresponding screen is created if it did not exist yet. To get rid of unused VTs, use deallocvt(1).) The key combination (Ctrl-)LeftAlt-FN (with N in the range 1-12) usually has a similar effect.

6
  • 3
    Could he have used startx as well? Just wondering.
    – n0pe
    Oct 27, 2011 at 5:50
  • 2
    @MaxMackie that should result in an error, since x server is already running.
    – blee
    Oct 27, 2011 at 6:58
  • You also need to run this as root
    – geek1011
    Nov 7, 2016 at 2:16
  • 1
    You may not need to run this as root if you use gdm where it starts a root-less display session as the user. In that case tty2 appears to be allocated for the user with tty7 for the gdm owned login window. If you switch to tty7 you have to login again and then it will push you back over to tty2 automatically, or you can simply switch to tty2 yourself.
    – dragon788
    Nov 21, 2017 at 19:24
  • This definitely helped out. I'm not sure why Ctrl+Alt+F7 no longer works to get back to the GUI vt, like it always used to. Thanks for the answer that's helped me sort myself out. Mar 21, 2018 at 13:01
25

Use the w command to find out which tty your X session uses, so you won't need to guess which Fn to press.

3
  • Here w lists tty1, tty2 and tty3 while X is running on tty12.
    – manatwork
    Feb 22, 2013 at 14:14
  • Exellect answer, just wordering. I go to console by pressing Ctrl-Alt-F1, see console tty1, unable to go back by the same combo. Use w, see I have 2 sessions tty1 and tty7, and return by pressing Ctrl-Alt-F7. Is It logical? Is It normal? Jan 23, 2018 at 7:25
  • 3
    what if my TTY is 0? there is no F0 button
    – szx
    Feb 7, 2019 at 9:07
21

You can simply use Alt+F1 to return to your desktop.

2
  • 4
    In the TTY, C-A-F# and A-F# are equivalent.
    – HalosGhost
    Oct 26, 2014 at 0:47
  • 1
    Yes. Surprise to me, after 20 years of X being on tty > 6 my current CentOS/KDM install uses tty1 May 25, 2018 at 1:10
4

You can use Alt+F6 to return to your desktop in Fedora 26 and possibly other Wayland based Linux flavors.

1
  • 1
    FFS, I don't know why this isn't the accepted answer. The OP gave their freaking OS in the question, and this is by FAR the least faffing about answer.
    – s.co.tt
    Aug 19, 2020 at 3:54
1

Toggle function-keys pressing "F-Lock" (german "F-Umsch")

Stumpling right into the same problem, I've found the reason for - at least - my problem: Using a ms natural 4000 keyboard sometimes requires to toggle the Function-keys pressing "F-Lock"-key located next to F12.

(Toggling the Function-Key's might help with that type of keyboard too if you don't get hardcopies etc...)

1
  • This is not the problem of the OP, thanks for the effort, though.
    – user79743
    Jan 18, 2016 at 1:38
0

Here's the English version of what the other answers said:

  1. First, log in if it asks you to do so.
  2. Then, run the w command. It will give you a tty# for your desktop GUI.
  3. Then, either press F# or run sudo chvt #, matching the # from step 2.
  4. If that doesn't work, panic.

You must log in to answer this question.

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