将其理解为 `ln (-s x) y`,而不是 `(ln -s) (x y)`。
我总是记不住 `ln -s x y` 的操作数顺序,现在我明白了原因:这个命令支持两种同时的解析方式。
`(ln -s) (x y)` — 这是我想要的理解。`-s` 表示“符号链接”,参数顺序与 `cp x y` 相同。没问题,但我对这种类比不太信任——尤其是在经历了 `find`、`dd` 或 `tar` 之后。
另外,出生时我们将符号链接称为 `x y`,但后来如果我们执行 `ls -l y`,就会看到 `y -> x`。为什么会反转?使用 `ln -s` 使得 `-s` 无法强制施加一种约定:只有链接本身被称为符号链接,至于这对操作数意味着什么,就得由我们自己去理解。
`ln (-s x) y` — 这是我的理解。`-s` 表示“源”。你是在声明 x 是新名称 y 的内容来源。
“但等一下,在符号链接术语中,x 被称为‘目标’!”这让我感到困惑。我一直把“源”和“目标”当作反义词,所以这个记忆法总是出错。但 x 实际上是两者:链接的目标,内容的源头。¹
所有指向某个资源的符号链接形成一棵以原始资源为根的树:
```
v1/ ← 原始资源
├── v2 (ln -s v1 v2)
│ └── v3 (ln -s v2 v3)
└── v4 (ln -s v1 v4)
```
每个带有 `-s` 的 `ln` 都扩展了一条分支。部分顺序 `x < y`(当且仅当 `ln -s x y`)甚至可以通过 `st_birthtime` 观察到——文件系统记录了哈斯图的构建历史。
简而言之:`ln -s old new` 将 `new` 推入以 `old` 为根的栈中。`-s` 是为了“源”,而不仅仅是“符号”。
---
¹ 就像拓扑学学生最终意识到一个集合可以既是闭合的又是开放的一样——这些词并不是反义词,只是独立的属性。我想知道什么样的正式拓扑框架可以使“源”和“目标”对应于“开放”和“闭合”。
查看原文
I could never remember the operand order for `ln -s x y`, and now I've realized why: the command supports two simultaneous parsings.<p>`(ln -s) (x y)` — the intended reading. `-s` for "symbolic," argument order same as in `cp x y`. Fine, but I don't trust such analogies — not after `find`, `dd`, or `tar`.<p>Also, it is weird how at birth we denote the symlink as `x y`, but later if we `ls -l y` we'll see `y -> x`. Why the reversal? Using `ln -s` makes `-s` powerless to impose a convention: only the link itself is qualified as symbolic, and it is left to us to figure out what that means for the operands.<p>`ln (-s x) y` — my reading. `-s` for "source." You're declaring x as the source of content for the new name y.<p>"But wait, x is called the 'target' in symlink terminology!" This was my confusion. I'd been treating "source" and "target" as antonyms, so the mnemonic kept breaking. But x is both: target of the link, source of the content.¹<p>All symlinks to a resource form a tree rooted at the original:<p>v1/ ← original<p><pre><code> ├── v2 (ln -s v1 v2)
│ └── v3 (ln -s v2 v3)
└── v4 (ln -s v1 v4)
</code></pre>
Each `ln` with `-s` extends a branch. The partial order `x < y` (iff `ln -s x y`) is even witnessed by `st_birthtime` — the filesystem records the Hasse diagram's construction history.<p>tl;dr: `ln -s old new` pushes `new` onto a stack rooted at `old`. The `-s` is for "source," not just "symbolic."<p>---<p>¹ Like how topology students eventually realize a set can be both closed and open — the words aren't antonyms, just independent properties. I wonder what formal topology scaffolding could make "source" and "target" correspond to "open" and "closed."