linux程序常见符号意思_Linux上符号链接的常见操作

linux程序常见符号意思

Symbolic link or soft link files are very common and useful on Linux/Unix systems. It works as a alias file for a file. You can create a symbolic links and it can operate transparently for most operations just as normal files. Programs that read or write to files named by a symbolic link behaves as if operating directly on the target file.

符号链接或软链接文件Linux / Unix 系统上非常常见且有用。 它用作文件的别名文件。 您可以创建一个符号链接,它可以像普通文件一样对大多数操作透明地运行。 读取或写入由符号链接命名的文件的程序的行为就像直接在目标文件上操作一样。

Let’s look at the common techniques and tools to play with symbolic link files on Linux.

让我们看一下在Linux上使用符号链接文件的常用技术和工具。

创建一个符号链接 (Create a symbolic link)

To create a symbolic link file in the current directory to a target file, say, ../target:

要在当前目录中创建到目标文件的符号链接文件,例如../target

$ ln -s ../target

This will create a symbolic link file target in the current directory.

这将在当前目录中创建一个符号链接文件target

You can also give it a different name, say tt:

您也可以使用其他名称,例如tt

$ ln -s ../target ./tt

检查文件是否是Bash中的符号链接 (Check whether a file is a symbolic link in Bash)

In Bash script, we can easily test whether a file is a symbolic link by the file test operator -h. For example:

在Bash脚本中,我们可以通过文件测试操作员-h轻松测试文件是否为符号链接。 例如:


if [ -h $file ]; then
    echo "a symbolic link"
fi

找出符号链接文件的目标 (Find out the target of a symbolic link file)

Use the readlink command.

使用readlink命令。

To find out the target of the ./tt we created:

为了找出./tt的目标,我们创建了:

$ readlink ./tt

With these basic tools, we can combine them with scripts to be some powerful tools.

使用这些基本工具,我们可以将它们与脚本结合起来成为一些强大的工具。

To find out the canonical target (dereference every symlink in every component) of the ./tt we created:

为了找出我们创建的./tt的规范目标(取消引用每个组件中的每个符号链接):

$ readlink -f ./tt

翻译自: https://www.systutorials.com/playing-with-symbolic-links-on-linux/

linux程序常见符号意思

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值