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.
More Here