LinuxCommandLibrary

chvt

Switch virtual terminal (console)

TLDR

Change to a specific TTY

$ sudo chvt [3]
copy

SYNOPSIS

chvt NUMBER

PARAMETERS

NUMBER
    The virtual terminal number (typically 1-63) to switch to. This must be an existing and valid VT number.

DESCRIPTION

chvt is a simple command-line utility used to change the foreground virtual terminal (VT) on a Linux system. Virtual terminals are separate console sessions that can be accessed simultaneously. Typically, Linux systems provide several VTs (e.g., tty1 through tty6 for text consoles, and often tty7 for the graphical environment like Xorg).

chvt allows a user with appropriate permissions to switch the active VT from one to another by specifying the VT number. This is useful for quickly moving between different console-based tasks or checking logs on a separate console without disrupting a running graphical session (though Xorg can interfere). It operates by sending a VT_ACTIVATE ioctl to the console device.

CAVEATS

chvt has a few important considerations:
1. Requires root privileges or sudo to execute, as changing the active virtual terminal is a system-wide operation.
2. Primarily effective on text-based consoles. When a graphical environment (like Xorg) is active, it often takes control of VT switching (e.g., using Ctrl+Alt+Fx), potentially blocking or altering chvt's behavior.
3. Does not create a new virtual terminal; it only switches to an already existing one. If the target VT is inactive, it will present a login prompt.

PERMISSIONS

For security and system stability, chvt requires elevated privileges, typically root access or execution via sudo. This is because switching virtual terminals is a global system action that could disrupt other users or processes, necessitating administrative control.

INTERACTION WITH XORG

When a graphical desktop environment (like Xorg) is running, it usually occupies a specific virtual terminal (e.g., tty7 on many systems). Xorg often intercepts and manages VT switching. While chvt can still be used to switch to a text console (e.g., tty1), returning to the active Xorg session might require specific graphical environment shortcuts (e.g., Ctrl+Alt+F7) rather than chvt itself.

HISTORY

chvt is a long-standing utility within the kbd (keyboard utilities) package. Its functionality is intrinsically linked to the Linux kernel's virtual terminal subsystem, a foundational component of the Linux console since the operating system's early development. The command itself has remained remarkably stable, with its core function unchanged over the years, reflecting the mature and robust design of the VT subsystem.

SEE ALSO

openvt(1), deallocvt(1), kbd(7), console(4), vc(4), login(1), getty(8)

Copied to clipboard