87447100 2020-01-30
目录
@
@auther 张念磊
@date 2020/1/30
命令英文:link
功能:创建一个链接
语法:ln [源文件] [生产的链接文件]
参数:
? -s 生成软连接
示例:
ln -s /etc/issue /tmp/issue.soft ln /etc/issur /tmp/issue.hard
权限
文件大小
箭头
echo 'zhangnlei.cn' >> /etc/issue
往文件底部附加一行数据
[_81_142_centos ~]# # 查看源文件 [_81_142_centos ~]# cat /etc/issue Centos 7 Kernel \r on an \m zhangnlei.cn [_81_142_centos ~]# [_81_142_centos ~]# # 添加软连接 [_81_142_centos ~]# ln -s /etc/issue /tmp/issue.soft [_81_142_centos ~]# cat /tmp/issue.soft Centos 7 Kernel \r on an \m zhangnlei.cn [_81_142_centos ~]# [_81_142_centos ~]# # 添加硬链接 [_81_142_centos ~]# ln /etc/issue /tmp/issue.hard [_81_142_centos ~]# cat /tmp/issue.hard Centos 7 Kernel \r on an \m zhangnlei.cn [_81_142_centos ~]# [_81_142_centos ~]# # 修改源文件 [_81_142_centos ~]# echo "zhangnianlei's blog" >> /etc/issue [_81_142_centos ~]# cat /etc/issue Centos 7 Kernel \r on an \m zhangnlei.cn zhangnianlei's blog [_81_142_centos ~]# cat /tmp/issue.soft Centos 7 Kernel \r on an \m zhangnlei.cn zhangnianlei's blog [_81_142_centos ~]# cat /tmp/issue.hard Centos 7 Kernel \r on an \m zhangnlei.cn zhangnianlei's blog [_81_142_centos ~]# [_81_142_centos ~]#
[_81_142_centos ~]# ll /etc/issue -rw-r--r-- 2 root root 63 1月 30 10:28 /etc/issue [_81_142_centos ~]# ll /tmp 总用量 16 -rw-r--r-- 2 root root 63 1月 30 10:28 issue.hard lrwxrwxrwx 1 root root 10 1月 30 10:23 issue.soft -> /etc/issue
文件权限:软连接的权限是全部允许,硬链接的权限和源文件相同
文件大小:硬链接与源文件一致,软连接较小。
[_81_142_centos ~]# # 查看i节点 [_81_142_centos ~]# ls -i /etc/issue /tmp/issue.soft /tmp/issue.hard 278955 /etc/issue 278955 /tmp/issue.hard 952 /tmp/issue.soft [_81_142_centos ~]#
删除源文件后: