硬连接软连接
来源:互联网 发布:城市地质数据涉及到 编辑:程序博客网 时间:2024/04/28 05:36
软连接和硬连接
创建连接:ln [option] source_dir dest_dir
例如有如下文件目录:/mnt/hy/hy.txt
/mnt/hello/hello.txt
1.目录的软连接:
(1)建立软连接: ln -s /mnt/hello /mnt/hy
则可以在/mnt/hy下看到hello目录的连接:
# ls -l
total 2
lrwxrwxrwx 1 root root 10 5月 27 14:25 hello -> /mnt/hello
-rw-r--r-- 1 root root 0 5月 27 14:22 hy.txt
(2)通过该连接进入hello目录,用pwd可以看到路径:
# pwd
/mnt/hello
在该目录下添加hello1.txt,进入/mnt/hello/,可以看到:
# ls -l
total 0
-rw-r--r-- 1 root root 0 5月 27 14:23 hello.txt
-rw-r--r-- 1 root root 0 5月 27 14:27 hello1.txt
(3).修改/mnt/hello的名字为/mnt/hi,其他不变:
进入/mnt/hy/:
# ls -l
total 2
lrwxrwxrwx 1 root root 10 5月 27 14:53 hello -> /mnt/hello
# cd hello
hello: does not exist
(4)删除/mnt/hy/下面的hello连接(与删除文件的方式一样),/mnt/hello未受影响。
由上面四点可以知道,目录的软连接是相当于windows下的快捷方式。文件的软连接亦类似。
2.文件的硬连接:
有如下文件目录:
/mnt/hy/hy.txt
/mnt/hello/hello.txt
其中:
hy.txt 内容为:this is hy.txt
hello.txt内容为:this is hello.txt
# ln /mnt/hello/hello.txt /mnt/hy
(1)、进入/mnt/hy,可以看到:
# ls -l
total 4
-rw-r--r-- 2 root root 18 5月 27 14:39 hello.txt
-rw-r--r-- 1 root root 15 5月 27 14:39 hy.txt
注意,hello.txt没有出现连接标志。
(2)修改hello.txt为如下:
this is hello.txt
flag=true.
返回/mnt/hello/
# more hello.txt
this is hello.txt
flag=true.
(3).删除/mnt/hello/hello.txt,然后到/mnt/hy/
# more hello.txt
this is hello.txt
flag=true.
这里的hello.txt未受影响。
3.比较
相同点:不同的入口,同样的内容。
不同点:
(1)软连接的对象可以是目录也可以是文件,硬连接的只能是文件。
(2), 软连接可以跨文件系统(如从window连接到linux下) ,硬连接不可以 (这个我没测试过)。
(3), 软连接可以对一个不存在的文件名进行连接,硬连接不可以。
(4),软连接的每个连接都相当于快捷方式,源文件不在了,所有的连接都会失效。硬连接的每个连接都相当于源文件的一个副本,即使源文件删除了,连接的文件一样存在。
- 硬连接软连接
- 软连接 硬连接
- 软连接,硬连接
- 软连接&硬连接
- 硬连接 软连接
- 软连接与硬连接
- linux 软连接 硬连接
- linux 软连接/硬连接
- Linux 硬连接 软连接
- linux 软连接 硬连接
- 软连接—硬连接
- 软连接和硬连接
- 硬连接和软连接
- 硬连接与软连接
- 软连接和硬连接
- 硬链接&软连接
- 软连接 硬链接
- 软连接 硬链接
- php的正则
- ARM汇编,MCR和MRC
- 五种JSP跳转方式比较
- 从程序员角度看ELF
- 余震中的生活~
- 硬连接软连接
- Understanding and Solving Internet Explorer Leak Patterns
- Understanding and Solving Internet Explorer Leak Patterns
- IT人才什么时候跳槽合适?
- 什么是Web 2.0
- 数据库设计中的14个关键技巧
- inline and _inline
- 实施经理的工具箱--走出软件作坊:三五个人十来条枪 如何成为开发正规军(五)
- 系统分析师修养