访问手机版  

Linux常用命令|Linux培训学习|考试认证|工资待遇与招聘,认准超级网工!

招聘|合作 登陆|注册

网络工程师培训

当前位置:网络工程师 > 技术课程 > linux > 热点关注 > linux常用命令

linux命令大全之ln命令详解(创建软链接和硬链接)

时间:2019-08-10

linux命令大全 ssh_linux命令大全_linux命令大全 root

命令:ll

输出:

代码如下:

[root@localhost test]# ll

lrwxrwxrwx 1 root root11 12-07 16:01 link2013 -> log2013.log

-rw-r--r-- 2 root bin61 11-13 06:03 ln2013

-rw-r--r-- 2 root bin61 11-13 06:03 log2013.log

[root@localhost test]# rm -rf log2013.log

[root@localhost test]# ll

lrwxrwxrwx 1 root root11 12-07 16:01 link2013 -> log2013.log

-rw-r--r-- 1 root bin61 11-13 06:03 ln2013

[root@localhost test]# touch log2013.log

[root@localhost test]# ll

lrwxrwxrwx 1 root root11 12-07 16:01 link2013 -> log2013.log

-rw-r--r-- 1 root bin61 11-13 06:03 ln2013

---xrw-r-- 1 root bin 302108 11-13 06:03 log2012.log

-rw-r--r-- 1 root root0 12-07 16:19 log2013.log

[root@localhost test]# vi log2013.log

2013-01

2013-02

2013-03

2013-04

2013-05

2013-06

linux命令大全 ssh_linux命令大全 root_linux命令大全

2013-07

2013-08

2013-09

2013-10

2013-11

2013-12[root@localhost test]# ll

lrwxrwxrwx 1 root root11 12-07 16:01 link2013 -> log2013.log

-rw-r--r-- 1 root bin61 11-13 06:03 ln2013

-rw-r--r-- 1 root root96 12-07 16:21 log2013.log

[root@localhost test]# cat link2013

2013-01

2013-02

2013-03

2013-04

2013-05

2013-06

2013-07

2013-08

2013-09

2013-10

2013-11

2013-12

[root@localhost test]# cat ln2013

hostnamebaidu=baidu.com

linux命令大全 ssh_linux命令大全_linux命令大全 root

hostnamesina=sina.com

hostnames=true

说明:

1.源文件被删除后linux命令大全,并没有影响硬链接文件;软链接文件在centos系统下不断的闪烁,提示源文件已经不存在

2.重建源文件后,软链接不在闪烁提示,说明已经链接成功,找到了链接文件系统;重建后,硬链接文件并没有受到源文件影响,硬链接文件的内容还是保留了删除前源文件的内容,说明硬链接已经失效

实例4:将文件链接为另一个目录中的相同名字

命令:ln log2013.log test3

输出:

代码如下:

[root@localhost test]# ln log2013.log test3

[root@localhost test]# ll

lrwxrwxrwx 1 root root11 12-07 16:01 link2013 -> log2013.log