From https://unix.stackexchange.com/a/17278/674

Local displays correspond to a socket in /tmp/.X11-unix.

(cd /tmp/.X11-unix && for x in X*; do echo ":${x#X}"; done)

On a computer:

$ (cd /tmp/.X11-unix && for x in X*; do echo ":${x#X}"; done)

I was wondering how to find out the X servers (command, or pid) for the given display numbers?


lsof /tmp/.X11-unix/X*

as root will list the commands and pids corresponding to each socket. You can then match the socket name to the display number, as you’ve done in your example.

  • So you're not gonna tell me how to grep these results to get pid or command, huh? – 炸鱼薯条德里克 Mar 15 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.