2

Out of curiosity i wanted to open a symlink as itself instead of the file it points to, just to see how it looks like. While there are ways to see what file it points to like using readlink and ways to copy symlinks themselves like cp -P, none of these allow you to see the actual contents of the symlink.

Is there a simple way to accomplish this? (either in plain text or in hexadecimal)

1 Answers1

4

Symlinks don't have any other content beside the link target, which you'd read with readlink().

As for symlink's metainfo. check lstat().

lstat() is identical to stat(), except that if pathname is a symbolic link, then it returns information about the link itself, not the file that it refers to.

ilkkachu
  • 138,973