如何在Linux中删除符号链接?

您所在的位置:网站首页 Linux删除连接 如何在Linux中删除符号链接?

如何在Linux中删除符号链接?

2024-07-14 03:06| 来源: 网络整理| 查看: 265

Symbolic links provides practical solutions file name or path related problems. Symbolic links will create same file or folder with different name and path. In some situations this may cause problem and we have to remove and delete symbolic link.

符号链接提供了实用的解决方案,文件名或路径相关的问题。 符号链接将使用不同的名称和路径创建相同的文件或文件夹。 在某些情况下,这可能会导致问题,我们必须删除和删除符号链接。

列出符号链接 (List Symbolic Links)

We can start by listing existing links especially symbolic links with ls command like below. Symbolic links provide some redirect to the source file like symbolic link RealInput.

我们可以通过如下所示的ls命令首先列出现有链接,尤其是符号链接。 符号链接提供了一些到源文件的重定向,例如符号链接RealInput 。

$ ls -lh List Symbolic Links List Symbolic Links 列出符号链接 删除符号链接(Remove Symbolic Links)

There are different ways to remove symbolic link. We can just issue rm command to the link file. In this example we will remote link named RealInput .

有多种方法可以删除符号链接。 我们可以向链接文件发出rm命令。 在此示例中,我们将名为RealInput远程链接。

$ rm RealInput 使用unlink命令删除 (Remove with unlink Command)

As we use ln command which is shortcut for link we have also command named unlinkwhich can unlink given links. In this example we can remove RealInput like below. unlink command is an alias for rm command.

当我们使用ln命令(它是链接的快捷方式)时,我们还使用了名为unlink命令,该命令可以取消链接给定的链接。 在此示例中,我们可以删除RealInput如下所示。 unlink命令是rm命令的别名。

$ unlink RealInput 使用sudo删除符号链接以解决“权限被拒绝”错误 (Remove Symbolic Links with sudo for “Permission Denied” Error)

Some symbolic links may be created by privileged user like root . If we try to remove this links with regular or less privileged user we will get an error like permission denied . So in order to remove this symbolic links we need to provide sudo command at the beginning of the command like below.

一些符号链接可能由root用户等特权用户创建。 如果我们尝试删除普通用户或特权较少的用户的此链接,则会收到类似permission denied的错误。 因此,为了删除此符号链接,我们需要在命令的开头提供sudo命令,如下所示。

$ sudo rm RealInput 删除硬链接 (Remove Hard Links)

We can easily remove hard links with the same commands too.

我们也可以使用相同的命令轻松删除硬链接。

$ unlink RealInput

OR

要么

$ rm RealInput LEARN MORE  What Does "rm -rf" Command Do In Linux? 了解更多信息“ rm -rf”命令在Linux中做什么?

翻译自: https://www.poftut.com/remove-symbolic-links-linux/



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3