创建test目录,在test下创建原文件a,软链接a.soft,硬链接a.hard,观察文件的区别;再分别修改三个文件的内容,观察文件之间内容的区别。删除a文件,在原路径下创建新的a文件,观察三个文件的区别后再修改文件内容,再观察内容的变化
[root@localhost /]# mkdir /test
[root@localhost /]# cd /test
[root@localhost test]# touch a
[root@localhost test]# ls
a
[root@localhost test]# stat a
File: a
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 17672764 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:default_t:s0
Access: 2023-03-10 09:23:51.917941724 +0800
Modify: 2023-03-10 09:23:51.917941724 +0800
Change: 2023-03-10 09:23:51.917941724 +0800
Birth: 2023-03-10 09:23:51.917941724 +0800
[root@localhost test]# ln /test/a a.hard
[root@localhost test]# ls
a a.hard
[root@localhost test]# ln -s /test/a a.soft
[root@localhost test]#
[root@localhost test]# ls
a a.hard a.soft
[root@localhost test]# ll
total 0
-rw-r--r--. 2 root root 0 Mar 10 09:23 a
-rw-r--r--. 2 root root 0 Mar 10 09:23 a.hard
lrwxrwxrwx. 1 root root 7 Mar 10 09:26 a.soft -> /test/a
[root@localhost test]# stat a a.hard a.soft
File: a
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 17672766 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:default_t:s0
Access: 2023-03-10 09:27:33.306044918 +0800
Modify: 2023-03-10 09:27:33.306044918 +0800
Change: 2023-03-10 09:27:33.306044918 +0800
Birth: 2023-03-10 09:27:33.306044918 +0800
File: a.hard
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 17672764 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:default_t:s0
Access: 2023-03-10 09:23:51.917941724 +0800
Modify: 2023-03-10 09:23:51.917941724 +0800
Change: 2023-03-10 09:27:12.704057373 +0800
Birth: 2023-03-10 09:23:51.917941724 +0800
File: a.soft -> /test/a
Size: 7 Blocks: 0 IO Block: 4096 symbolic link
Device: fd00h/64768d Inode: 17672761 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:default_t:s0
Access: 2023-03-10 09:26:06.897413083 +0800
Modify: 2023-03-10 09:26:02.709128489 +0800
Change: 2023-03-10 09:26:02.709128489 +0800
Birth: 2023-03-10 09:26:02.709128489 +0800
[root@localhost test]# echo 123 > a
[root@localhost test]# cat a a.hard a.soft
123
123
123
[root@localhost test]# echo 222> a.hard
[root@localhost test]# cat a a.hard a.soft
222
222
222
[root@localhost test]# echo 333> a.soft
[root@localhost test]# cat a a.hard a.soft
333
333
333
[root@localhost test]# rm a
rm: remove regular file ‘a’ ? y
[root@localhost test]# ls
a a.hard a.soft
[root@localhost test]# ll
total 4
-rw-r--r--. 1root root 4 Mar 809:23 a.hard
lrwxrwxrwx. 1 root root 7 Mar 8 09:26 a.soft -> /test/a
[root@localhost test]# cat a a.hard a.soft
333
Cat : a.soft : No such file or directory
[root@localhost test]# echo 123 > a
[root@localhost test]# cat a a.hard a.soft
123
333
123
[root@localhost test]# stat a a.hard a.soft
File: a
Size: 4 Blocks: 8 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 17672766 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:default_t:s0
Access: 2023-03-10 09:27:33.306044918 +0800
Modify: 2023-03-10 09:27:33.306044918 +0800
Change: 2023-03-10 09:27:33.306044918 +0800
Birth: 2023-03-10 09:27:33.306044918 +0800
File: a.hard
Size: 4 Blocks: 8 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 17672764 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:default_t:s0
Access: 2023-03-10 09:23:51.917941724 +0800
Modify: 2023-03-10 09:23:51.917941724 +0800
Change: 2023-03-10 09:27:12.704057373 +0800
Birth: 2023-03-10 09:23:51.917941724 +0800
File: a.soft -> /test/a
Size: 7 Blocks: 0 IO Block: 4096 symbolic link
Device: fd00h/64768d Inode: 17672761 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:default_t:s0
Access: 2023-03-10 09:26:06.897413083 +0800
Modify: 2023-03-10 09:26:02.709128489 +0800
Change: 2023-03-10 09:26:02.709128489 +0800
Birth: 2023-03-10 09:26:02.709128489 +0800