Have you ever had to determine the virtual terminal that an X session is running on? Perhaps you may want this information for a program you have created. It is possible using the fgconsole command.
Just running fgconsole will print the number of the active virtual terminal. For the uninitiated, by default, you have 7 virtual terminals on your Linux machine. You can switch between them using the Ctrl+Alt+<Fn> key sequence.
Usually, your Linux machine will be using any virtual terminal which is available for displaying X. But if the following two parameters are enabled in your /etc/gdm/gdm.conf file, then it will always use the same terminal.
You may also do the following to see which virtual terminal your X session is using :
$ grep VT /var/log/Xorg.0.log
(++) Using VT number 7