Why are there infinitely many x11 subdirectories in /usr/bin/x11?

Why does the /usr/bin/x11 folder hold another x11 folder and when you open that x11 you get another x11 and then another and another?

I did it about 6 times and got frustrated so I have no idea how deep this goes but

  • What is the purpose (or is it a glitch?)?
  • Is this eating disk space more than it should? (I was going to delete one or more but thought I better ask first )

I can see no reason why this should be happening at all.


Solution 1:

/usr/bin/X11/ is a symbolic link (symlink) pointing to /usr/bin/. Hence it contains itself and you can follow those X11 folders all day long but there's still just one on your disk.

This is for compatibility reasons as some programs expect some other program to be in /usr/bin/X11/ but Ubuntu puts them in /usr/bin/.

Solution 2:

/usr/bin/X11 is not a directory but a file, specifically a symbolic link. Use

$ ll /usr/bin/X11
lrwxrwxrwx 1 root root 1 dec  3 13:01 /usr/bin/X11 -> ./

to see that it is a link (l as first letter in the answer) and that it points to the containing directory ./, while keeping on existing as a file inside that directory.

It's like a window giving a view on the inside of a shop --- you can sneak inside from outside, but you can also see the same window as a part of the whole shop.

More concisely, you can discover this also with

$ realpath /usr/bin/X11
/usr/bin

since realpath resolves the target of links and gives its absolute path. (In some distribution realpath is a core utility that needs to be installed, and it's useful to have.)