Readlink resolves symlinks. I'm not sure how I went so long using linux without knowing about this, but it's awesome. On a system of mine, /usr/bin/java points to /etc/alternatives/java which points to /usr/lib/jvm/java-1.6.0-openjdk- It would take two rounds of 'ls -l' to figure out where the real file is.

Or run:


readlink -f $(which java)


The '-f' flag follows all of the links to the real source. Without the '-f' flag, this would have returned /etc/alternatives/java.

More information at

Return to Categories