ln

更新时间:
2025-01-03

ln

创建符号链接文件。

格式

ln [-s | -h | -f] [actualpath] [linkpath]

说明

[root@sylixos:/root]# help ln
create a hard or symbol link file (default creating symbol link).
eg. ln -s /tmp/dir /dir
ln [-s | -h | -f] [actualpath] [linkpath]
[root@sylixos:/root]# 

此命令用来创建符号链接文件。该命令有2种用法;

  • 无选项:默认创建软链接文件。
  • 选项 -s:表示创建软链接文件。
  • 选项 -h:表示创建硬链接文件。
  • 选项 -f:表示强制创建,需要搭配选项 -s 或 -h 使用。

actualpath 为实际路径,linkpath 为链接文件名。

样例

[root@sylixos:/root]# ln test_file link1
[root@sylixos:/root]# ln -s test_file link2
[root@sylixos:/root]# ln -h test_file link3
[root@sylixos:/root]# ll
lrwxrwxrwx root     root     Sat Jan 01 10:10:04 2000           link1 -> test_file
-rw-r--r-- root     root     Sat Jan 01 08:46:03 2000  10240KB, link3
-rw-r--r-- root     root     Sat Jan 01 08:46:03 2000  10240KB, test_file
lrwxrwxrwx root     root     Sat Jan 01 10:10:24 2000           link2 -> test_file
      total items: 4
[root@sylixos:/root]# 

备注:
仅TpsFs文件系统支持硬链接创建

文档内容是否对您有所帮助?
有帮助
没帮助