Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

chvt

Switch the screen of the machine to another virtual terminal (tty1 … tty12).

Level
Everyday Linux
Group
Shell and help
Needs root
Yes
Package
kbd

What it does

chvt N makes /dev/ttyN the active console, like pressing Ctrl+Alt+FN. It is useful when you work on a machine through a remote tool that cannot send Ctrl+Alt key combinations, or from a script.

You must be root (or own the console) to switch.

How to write it

chvt [OPTION] N

Options 3

Most used

N
The number of the virtual terminal (1 to 12, or more).
-h, --help
Show help.
-V, --version
Show the version.

Examples 10

$ run as a normal user# run as root (or with sudo)

  1. 1Go to the third text console

    chvt 3

    Same as Ctrl+Alt+F3.

  2. 2Go back to the graphical login screen

    chvt 1

    On RHEL with a desktop, tty1 is the login screen.

  3. 3Switch to your graphical session

    chvt 2

    On RHEL your desktop session usually runs on tty2.

  4. 4Use it over SSH to show a console to a colleague

    chvt 4

    The physical screen in the server room changes.

  5. 5See which terminal is active

    cat /sys/class/tty/tty0/active
    tty2

    Shows the active virtual terminal.

  6. 6Switch when the remote console cannot send Ctrl+Alt+F keys

    chvt 3

    Many web consoles of virtual machines catch these keys.

  7. 7Free a virtual terminal that is not used

    deallocvt 7

    Removes unused consoles from memory.

  8. 8Open a login on another console from a script

    openvt -c 5 -- /bin/login

    Starts a login program on tty5.

  9. 9Check which consoles have a login prompt

    systemctl list-units 'getty@*'

    Each text console with a login prompt is a getty service.

  10. 10Switch back after maintenance

    chvt 1

    Leave the screen at the login prompt.

Watch out

  • chvt changes the physical screen. Users on the console notice it.

Tips to remember

  • chvt N = Ctrl+Alt+FN from the command line.

Full manual

This page explains the command in simple words. The original manual has every detail.

In your terminal: man chvt