I have written a program that performs health checks on servers. One of its functions is that it can check whether or not a symlink exists. I am currently in the process of writing unit tests (for use with Travis CI), and I'm wondering if there are any symlinks that I can depend on being there on any Linux system.

For example, I currently unit test with /bin/sh, which is usually a symlink to something like /bin/bash.

Does Linux have a set of symlinks that are there by default?

closed as too broad by mattdm, Anthon, cuonglm, slm Jul 17 '15 at 16:48

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Why not just make a symlink as part of the setup for the unit test? /bin/sh does not have to be a symlink. – jordanm Jul 17 '15 at 14:50
  • 1
    Linux is a kernel. Nothing else. The operating systems using Linux as kernel differ a lot. – yeti Jul 17 '15 at 14:51
  • There are a number standard symlinks in /proc, but I don't think there is any "universal" symlink in a real filesystem. The various distributions are quite different from one another, even if you consider, say, only desktop-class systems. – lcd047 Jul 17 '15 at 14:57

No, because there is no standard Linux distribution. Linux is just a kernel, and doesn't specify anything about user-space, including file layout. If you want to narrow this down to a subset of Linux distributions, you might be able to find something (with, as you note, /bin/sh as a good candidate)

However, the kernel itself does have some special fileystems, notably /proc and /sys, which are part of the kernel directly, and which contain symlinks. Therefore, for example:

$ file /proc/$$/exe
/proc/7622/exe: symbolic link to `/usr/bin/bash'

However, I'm not sure I'd rely on this for your tests, because a) proc might actually not be available within every testing system, and b) since it's not a real filesystem, it seems a little dodgy. Why not just create your own symlink as part of your test?

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