Linux Commands Examples

A great documentation place for Linux commands

fgconsole

print the number of the active VT.


see also : chvt

Synopsis

fgconsole [--help|--version|--next-available]


add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!

examples

0
source
            
[[ $(fgconsole 2>/dev/null) == 1 ]] && exec startx -- vt1
0
source
            
. $HOME/.bashrc
[[ "$(fgconsole 2>/dev/null)" == "1" ]] && exec xxx
0
source
            
vt=$(fgconsole 2>/dev/null)
(( vt == 1 )) && exec startx -- vt$vt &> ~/.xlog
unset vt

description

If the active Virtual Terminal is /dev/ttyN, then prints N on standard output.

If the console is a serial console, then "serial" is printed instead.
--next-available

Will show the next unallocated virtual terminal. Normally 6 virtual terminals are allocated, with number 7 used for X; this will return "8" in this case.

notes

Under devfs, the consoles are in /dev/vc/N. devfsd may maintain symlinks for compatibility.


see also

chvt .

How can this site be more helpful to YOU ?


give  feedback