What does the "size" of a symlink represent in ls output?

Symbolic links take the room it takes to store the name and target plus a few bytes for other metadata.

So it is the size of the symlink.

Regarding the size from du -sh: du only looks at how many blocks are allocated, and so may show 0.stat and ls -l are better in showing the size in that regard.


It is the size of the symlink in bytes.

Some file systems have a small area inside the directory entry that is used for the beginning of the file, which significantly speeds up processing of symlinks and small reads (think file) at the expense of larger directory entries.

If the entire symlink contents fit into the directory entry, then no data blocks are allocated, and the du size shows as zero. If the symlink doesn't fit, space is allocated normally (so you end up with a single block allocation), which may be optimized by the filesystem using tail merging (but there is no API for du to know about this).

The ext4 filesystem performs this optimization for symlinks only, the criteria are found in the function ext4_inode_is_fast_symlink.