如何使用控制台命令在 Linux 和 OpenBSD 中更改虚拟 ttys?

gee*_*eek 22 linux unix bsd openbsd tty

在 Linux 中,按Alt- F1Alt-F2等来更改虚拟 tty。

在 OpenBSD 中,应使用Ctrl- Alt-F1等代替。

是否有针对这两个操作系统的控制台命令可以发出来实现这个目标?当一个操作系统在另一个使用某个虚拟机的操作系统中作为来宾运行时,使用按键有时会产生干扰。

小智 29

是的,您可以使用该chvt命令。这需要sudo权限才能运行。

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.
Run Code Online (Sandbox Code Playgroud)

您可以通过fgconsole命令找到您当前所在的虚拟终端。这也需要 sudo 权限才能运行。