fgconsole

print foreground virtual terminal number

TLDR

Print current terminal number
$ fgconsole
Print next unallocated virtual terminal number
$ fgconsole --next-available

SYNOPSIS

fgconsole [options]

DESCRIPTION

fgconsole prints the number of the foreground virtual terminal. If the terminal is serial, it prints "serial" instead of a number.Part of kbd package for console management utilities.

PARAMETERS

-n, --next-available

Print next unallocated VT number
-V, --version
Print version number and exit
-h, --help
Display help and exit

INSTALL

sudo apt install kbd
sudo dnf install kbd
sudo pacman -S kbd
sudo apk add kbd
sudo zypper install kbd
nix profile install nixpkgs#kbd

CAVEATS

Only works on Linux console. Returns error if not on a virtual terminal. Part of kbd package.

SEE ALSO

chvt(1), deallocvt(1), dumpkeys(1)