TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Difference Between a Symbolic Link and a Hard Link

25 pointsby sine_breakabout 2 years ago

5 comments

adrianmonkabout 2 years ago
What made it click for me mentally was this thought: <i>there&#x27;s no such thing as a hard link</i>. Or alternatively, <i>every file is a hard link</i>.<p>Files don&#x27;t have names. At least, they don&#x27;t have names for themselves. Instead, they have unique ids (i-node numbers).<p>But obviously we use names for files, which happens because a directory can give a name to a file. However, the name is just <i>that</i> directory&#x27;s name for the file.<p>There is no rule against multiple directories each giving their own name to a file, and there is no rule against one directory giving multiple names to a file.<p>So a &quot;hard link&quot; is not some special, different type of thing. It&#x27;s another instance of the same type of thing that happened when you first created the file. So it&#x27;s clearer (to me) to either not think of any of them as hard links or to think of all of them as hard links.
评论 #35504153 未加载
linsomniacabout 2 years ago
HP used to have a thing called Context Dependent Files (maybe still does?) that was part of their discless clustering. It was like a symlink, but instead of being a file that contains the name of another path, it was a directory of files. The files were named things like system architecture (m68k), and hostname, and the kernel would search for a match using some precedence rules, then treat it like a symlink.<p>So on your NFS mount you could have different files for, say, &#x2F;bin&#x2F;ls, based on architecture, or &#x2F;etc&#x2F;hostname that differed by the name of the host.<p>I always thought CDFs were pretty clever, but they never seemed to gain any traction.
leroy-is-hereabout 2 years ago
Back in the old days, I had some sort of arcane chroot setup for FTP for this website. I used a hard link to resolve everything. Well, like a year into it, I forgot that I used a hard link. I needed to update a few things, so I just rm’d the supposed sym link and nuked the entire site.<p>Learned a hard lesson about backups that day. I did have some, but of course we still lost some data.
评论 #35503127 未加载
jasoneckertabout 2 years ago
It&#x27;s also worth noting that hard links are &quot;harder&quot; to view and find compared to symbolic links (symlinks) and are primarily used for administrative instead of user purposes. Modern terminals display symlinks with colour, the -F option to ls appends @ to symlinks, and the -l option displays the target.<p>Hard links are only indicated by a link count &gt;1 for files, but to find them, you must search by inode number (since they all share the same inode number) - e.g., ls -i to list inode numbers, and find &#x2F; -inum 1234 (for inode 1234) to find them on the same filesystem.
评论 #35503065 未加载
tyingqabout 2 years ago
Feels like this article should also mention reflinks.