Sample Header Ad - 728x90

Why do hard links seem to take the same space as the originals?

33 votes
3 answers
29621 views
Thanks to some good Q&A around here and [this page](http://linuxgazette.net/105/pitcher.html) , I now understand links. I see hard links refer the same inode by a different name, and copies are different "nodes, with different names. Plus soft links have the original file name and path as their inode, so if the file is moved, the link breaks. So, I tested what I've learnt with some file ("saluton_mondo.cpp" below), made a hard and a soft link and a copy. jmcf125@VMUbuntu:~$ ls -lh soft hard copy s*.cpp -rw-rw-r-- 1 jmcf125 jmcf125 205 Aŭg 27 16:10 copy -rw-rw-r-- 2 jmcf125 jmcf125 205 Aŭg 25 13:34 hard -rw-rw-r-- 2 jmcf125 jmcf125 205 Aŭg 25 13:34 saluton_mondo.cpp lrwxrwxrwx 1 jmcf125 jmcf125 17 Aŭg 27 16:09 soft -> saluton_mondo.cpp I found awkward that the hard link, however, has the same size as the original and, logically, the copy. If the hard link and the original share the same inode, that has the data, and only differ by the filename, shouldn't the hard link take only the space of its name, instead of 205 bytes? Or is that the size of the original file that ls -lh returns? But then how can I know what space does the filename take? [Here](https://unix.stackexchange.com/questions/20670/why-do-hard-links-exist#answer-20716) it says hard links have no size. Is their file name kept alongside the original file name? Where is the file name of hard links stored?
Asked by JMCF125 (1132 rep)
Aug 27, 2013, 03:48 PM
Last activity: Dec 28, 2024, 03:48 PM