如何在 Linux 中取消链接/删除符号

在这篇文章中,将介绍删除符号链接的简单步骤

假设你有一个如下所示的链接

# ls -l
drwxr-xr-x.  2 root root  4096 Sep 12 13:55 Desktop
lrwxrwxrwx   1 root root     7 Jan 10 23:34 shortcut -> Desktop

这里的shortcut是Desktop的符号链接

方法一

说明:

永远记住,我们必须删除创建的快捷方式链接,而不是原始目录。

# rm shortcut

方法二

# unlink shortcut/
unlink: cannot unlink `shortcut/': Not a directory

为什么我收到这个错误?

这是因为链接末尾有一个正斜杠,不应该存在,因为它是链接而不是目录,因此我们只需要指定必须删除的链接。

让我们再试一次

# unlink shortcut

现在命令运行没有任何错误。
同样可以使用“ls -l”进行验证

日期:2020-06-02 22:18:34 来源:oir作者:oir