Change The Current Text Console Using chvt

You all know you can change from one text console to another using ALT-Fx, where x is a number from 1 to 7 (or even higher, depending on your configuration).

What is not so widely known, is that you can also change consoles with a nifty little program called chvt.

Example: chvt 3 (this switches to console 3)

There are several reasons why this utility can be quite handy: First, you might want to write shell/perl/whatever scripts which switch the consoles, which you can do now. Second, if something with your X11 keyboard configuration screws up (e.g. ALT-keys don't work anymore) or something similar, you can still switch to a console.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

yes, but can you do this...?

Does anyone know a way to determine the "currently active" virtual terminal? As in the one currently being displayed on the console. I'd be terribly interested in being able to do that.

running fgconsole as root

running fgconsole as root will tell you the current active VT.


Sure, just run tty, that prints the current terminal.

that does not answer the

that does not answer the question !

Another useful thing

Another useful thing you can do with chvt?

You can "wake up" sleeping monitors. If you were running a lab, for example, you can set up a simple cron job that goes

chvt 1 !!
chvt 7 !!

and boom, all the working computers wake up at the same time.

and if you could not access

and if you could not access the local computer's terminal (eg. Xorg freezed and ctrl-alt-f1 does no effect) you can use ssh+conspy at a remote machine!

$ ssh blocked-host
# conspy 1 # may needs root privileges
$ chvt 1; chvt 7


Nice hack ;) Thanks for sharing. Uwe.