将其理解为 `ln (-s x) y`,而不是 `(ln -s) (x y)`。

2作者: _as_text大约 23 小时前原帖
我总是记不住 `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&#x27;ve realized why: the command supports two simultaneous parsings.<p>`(ln -s) (x y)` — the intended reading. `-s` for &quot;symbolic,&quot; argument order same as in `cp x y`. Fine, but I don&#x27;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&#x27;ll see `y -&gt; 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 &quot;source.&quot; You&#x27;re declaring x as the source of content for the new name y.<p>&quot;But wait, x is called the &#x27;target&#x27; in symlink terminology!&quot; This was my confusion. I&#x27;d been treating &quot;source&quot; and &quot;target&quot; 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&#x2F; ← 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 &lt; y` (iff `ln -s x y`) is even witnessed by `st_birthtime` — the filesystem records the Hasse diagram&#x27;s construction history.<p>tl;dr: `ln -s old new` pushes `new` onto a stack rooted at `old`. The `-s` is for &quot;source,&quot; not just &quot;symbolic.&quot;<p>---<p>¹ Like how topology students eventually realize a set can be both closed and open — the words aren&#x27;t antonyms, just independent properties. I wonder what formal topology scaffolding could make &quot;source&quot; and &quot;target&quot; correspond to &quot;open&quot; and &quot;closed.&quot;