linux - symbolic - symlink centos
is there a way to see the actual contents of a symlink? (3)
When you do
it shows the contents of the real file, not what is within the symlink itself. Is there a way to see what's actually in it?
Regarding to man page http://man7.org/linux/man-pages/man7/symlink.7.html symlink is regular file (with special flag) with path to target in its content. So you could copy symlink to FAT partition and read it content there.
ls -l command will show you that:
$ ls -l foo lrwxrwxrwx 1 user group 11 2010-12-31 19:49 foo -> /etc/passwd
$ readlink foo /etc/passwd
So, the symbolic link
foo points to the path
You can call the
readlink(2) function, which will place the linked-to name into a buffer.
Note that the result has a length (stored in the return value) rather than being NUL-terminated. So if you want to use it as a string, append a NUL yourself.
Most higher-level/scripting languages, such as perl or python, will provide a readlink wrapper that converts to the usual language-appropriate string type, so you won't be bothered by details such as NUL-termination.