2

I want to know on which virtual console the X11 is runnning. Of course, I can know it by invoking the ps command and watching the process tree. Or, I can know it by pressing ctrl+alt+F1, ctrl+alt+F2, ... But it is nice if there is an easier way.

When the system is in CUI mode, I can know it by the tty command. But under X11, the tty command tells me such as /dev/pts/0 and it doesn't seem to be a clue to the virtual console. Is there is any connection between tty* and pst/*?

In my environment, X11 is usually running on tty1. But in some rare case, it runs on another console. If I can know the console easily, it helps me a lot.

P.S.

Recently I knew the following fact:

On machies using systemd, the environment variable $XDG_VTNR is set to the number of the virtual console.

What is the environment variable XDG_VTNR?

2 Answers 2

4

You can use the fgconsole command. In Debian it's included in the package kbd.

For example:

$ fgconsole 7 
1

You could always run grep "using VT number " /var/log/Xorg.0.log. I'll leave it to you on how to extract the number.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.