What does "Ctrl + Alt + F12" do?

Solution 1:

Pressing Ctrl+Alt+Fn (or just Alt+Fn when not in X11, the GUI) switches to the nth virtual console (ttyn).

Often we talk about a virtual console as a usable text console. So we often say there are six virtual consoles, accessible with Alt+F1 through Alt+F6 (holding down Ctrl too if you're in the GUI when you want to switch). And we often say that then, separately, is the GUI, which can be switched (back) to with Alt+F7.

But in fact, tty7, where the GUI typically runs, is a virtual console too. It's just not usable as a text console, because it doesn't have getty running for it. getty runs for tty1 through tty6 (by default). getty sets a virtual console up to be used like a terminal and runs login to prompt for a username and password.

You can see the getty commands that are running by filtering the output of ps:

ek@Kip:~$ ps ax | grep -v grep | grep getty
 1127 tty4     Ss+    0:00 /sbin/getty -8 38400 tty4
 1150 tty5     Ss+    0:00 /sbin/getty -8 38400 tty5
 1171 tty2     Ss+    0:00 /sbin/getty -8 38400 tty2
 1172 tty3     Ss+    0:00 /sbin/getty -8 38400 tty3
 1175 tty6     Ss+    0:00 /sbin/getty -8 38400 tty6
11231 tty1     Ss+    0:00 /sbin/getty -8 38400 tty1

Since tty7 is the first virtual console that is not set up to behave like a terminal (i.e., no getty is running for it), that's the one X11 (which provides the GUI) uses.

Virtual consoles higher than tty7 exist also. It's just that, ordinarily, they neither have getty running for them, nor do they have X11 using them. The first 12 virtual consoles are accessible with the key combinations described above using function keys (because a keyboard typically has only 12 numbered function keys). They are accessible even if nothing is happening on them.

Thus, when you press Ctrl+Alt+F12, you get a blank screen because you are now on tty12, which has nothing at all running on it.

As an interesting exercise, you might try running:

sudo /sbin/getty -8 38400 tty12

Then press Alt+F12 (or Ctrl+Alt+F12 if you're in the GUI rather than one of the first 6 virtual consoles).

This will bring you to tty12, which now has a login screen and is usable as a terminal.

(If you wanted to permanently create usable text-based consoles on higher-numbered virtual consoles, then you should configure init to run getty for them automatically. When getty is run manually as above, or even if you were to add that line to a startup script, you won't get the ability to login again after logging out on the virtual console, because getty won't automatically run again. Furthermore, there are some other problems running getty in that way for production use--for example, bash job control might not be available in your login shell, after you log in. If you want to make more virtual consoles usable as text-based terminal emulators, I recommend asking a separate question about that.)

Solution 2:

Here is a brief explanation:

The following Keys are for going to the Terminal (The black background, white letters way):

Ctrl+Alt+F1 - Will send user to tty1 or 1st Terminal

Ctrl+Alt+F2 - Will send user to tty2 or 2nd Terminal

Ctrl+Alt+F3 - Will send user to tty3 or 3rd Terminal

Ctrl+Alt+F4 - Will send user to tty4 or 4th Terminal

Ctrl+Alt+F5 - Will send user to tty5 or 5th Terminal

Ctrl+Alt+F6 - Will send user to tty6 or 6th Terminal

For GUI Terminals (Where X is typically running, or better said, where you land when Unity appears and everything looks good. The default one where you start the GUI would be F7):

Ctrl+Alt+F7 - Will send user to the 1st GUI Terminal

Ctrl+Alt+F8 - Will send user to the 2nd GUI Terminal

Ctrl+Alt+F9 - Will send user to the 3rd GUI Terminal

Ctrl+Alt+F10 - Will send user to the 4th GUI Terminal

Ctrl+Alt+F11 - Will send user to the 5th GUI Terminal

Ctrl+Alt+F12 - Will send user to the 6th GUI Terminal

The thing to note here is that you can go from one terminal to the other by pressing the corresponding keys. You should also note that, since you are running one instance of the X server (one Unity running) you will only have F7 working for the GUI Terminals. If you open another X Server session, it will start in F8 and you can switch between both by pressing the correct keys. You can keep doing this for a total (default) of 6 times which would be F7 up to F12.

Solution 3:

You can come back to any of normal GUI in Ubuntu from any of the TTY screens by hitting:
Ctrl+Alt+F7