TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Difference Between a Symbolic Link and a Hard Link

25 点作者 sine_break大约 2 年前

5 条评论

adrianmonk大约 2 年前
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 未加载
linsomniac大约 2 年前
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-here大约 2 年前
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 未加载
jasoneckert大约 2 年前
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 未加载
tyingq大约 2 年前
Feels like this article should also mention reflinks.