You didn't provide additional details, so this explanation is for the moment centered on the EXT file systems common in Linux.
If you look at the "size" of a symlink as provided by e.g. ls -l
, you will notice that the size is just as large as the name of the target it is pointing to is long. So, you can infer that the "actual" file contains just the path to the link target as text, and the interpretation as a symbolic link is stored in the filetype metadata (in particular, the flag S_IFLINK
in the i_mode
field of the inode the link file is attached to, where also the permission bits are stored; see this kernel documentation reference).
In order to improve performance and reduce device IO, if the symlink is shorter than 60 bytes it will be stored in the i_block
field in the inode itself (see here). Since this makes a separate block access unnecessary, these links are called "fast symlinks" as opposed to symlinks pointing to longer paths, which fall back to the "traditional" method of storing the link target as text in an external data block.
cat --do_not_follow
to display just the "path to the target" in plain text? – midnite Dec 14 '21 at 18:24cat
will usually try to work as universally as possible. (2) Even on EXT filesystems, the link target is not stored in the file content if the path length is short, so it would be an option with very limited scope. – AdminBee Dec 15 '21 at 13:54