Sunday, May 6, 2018

Switching the VT from the command line

Just for fun, I wondered how to change the virtual terminal from the command line.

You can switch with CTRL+ALT+F1 through F7 (or go as high as F12) but how do you do it with a command?


chvt will switch you to the virtual terminal.


So if you type this from an Ubuntu 17.10 terminal window:


sudo chvt 5; sleep 2; sudo chvt 2

That will switch you to vt 5, sleep for a couple of seconds, then switch you back to the graphics screen desktop on vt 2.

Silly fun!

What's kind of interesting is that if you do something like:


sudo chvt 5; date; sleep 2; date; sudo chvt 2; date


the system doesn't actually update the graphics screen with the output of the date commands until you have switched back to the graphics screen on vt 2.

No comments:

Post a Comment