Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Linux one presses Alt-F1, Alt-F2 etc to change virtual ttys.

In OpenBSD one shall use Ctrl-Alt-F1 etc instead.

My question is if there are console commands for these two operating systems that can be issued to achieve this goal. The reason I'm looking for these is that the key presses sometimes interfere when an OS is being run as guest inside another one using some virtual machine.

share|improve this question

1 Answer 1

up vote 9 down vote accepted

Yes, you can using the chvt command. This needs sudo privileges to run.

CHVT(1)

NAME

chvt - change foreground virtual terminal

SYNOPSIS

chvt N

DESCRIPTION

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 )
The key combination (Ctrl-)LeftAlt-FN (with N in the range 1-12) usually has a similar effect.

You can find the virtual terminal you're currently on via the fgconsole command. This too requires sudo privileges to run.

share|improve this answer
    
Thanks, it works for Linux, but OpenBSD doesn't have a chvt command. –  geek Sep 1 '09 at 7:04
    
For OpenBSD, try this code: cs.cmu.edu/~joshuad/wsswitch.c. It uses the same ioctl(fd,VT_ACTIVATE,screen_no) call. Referred to from: cs.cmu.edu/~joshuad/libretto.html –  nagul Sep 1 '09 at 9:07
    
Perfect. Trying to remote into my machine (X11VNC) and the gui was frozen. Turns out it was because I had switched it to another vt (cli), and apparently X11 (vnc?) freezes unless the current VT is X's VT. –  EkriirkE May 3 at 21:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.