软硬链接。

用户通过SSH连接到远程Linux服务器,创建了一个名为SZ的文件并用它创建了硬链接HARD.SZ和软链接SOFT.SZ。通过不同链接修改文件内容,展示了硬链接和软链接的区别。最后,删除原始文件SZ后,软链接失效。
摘要由CSDN通过智能技术生成

[C:\~]$ ssh 192.168.232.128


Connecting to 192.168.232.128:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Activate the web console with: systemctl enable --now cockpit.socket

Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last login: Wed Mar  8 20:04:28 2023 from 192.168.232.1
[root@localhost ~]# ll
total 4
-rw-------. 1 root root 921 Mar  4 12:06 anaconda-ks.cfg
[root@localhost ~]# cd /
[root@localhost /]# ls
afs  bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[root@localhost /]# mkdir test
[root@localhost /]# ls
afs  bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  test  tmp  usr  var
[root@localhost /]# cd /test/
[root@localhost test]# ls
[root@localhost test]# touch SZ
[root@localhost test]# ls
SZ
[root@localhost test]# man ln
[root@localhost test]# ln /test/SZ SZ.hard
[root@localhost test]# ls
SZ  SZ.hard
[root@localhost test]# ln -s /test/SZ SZ.soft
[root@localhost test]# ls
SZ  SZhard  SZ.soft
[root@localhost test]# ll
total 0
-rw-r--r--. 2 root root  0 Mar 10 16:12 SZ
-rw-r--r--. 2 root root  0 Mar 10 16:12 SZ.hard
lrwxrwxrwx. 1 root root 12 Mar 10 16:17 SZ.soft -> /test/SZ
[root@localhost test]# stat SZ SZ.hard SZ.soft
  File: SZ
  Size: 0             Blocks: 0          IO Block: 4096   regular empty file
Device: fd00h/64768d    Inode: 1269702     Links: 2
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:default_t:s0
Access: 2023-03-10 16:12:01.128572749 +0800
Modify: 2023-03-10 16:12:01.128572749 +0800
Change: 2023-03-10 16:15:00.855248561 +0800
 Birth: 2023-03-10 16:12:01.127572782 +0800
  File: SZ.hard
  Size: 0             Blocks: 0          IO Block: 4096   regular empty file
Device: fd00h/64768d    Inode: 1269702     Links: 2
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:default_t:s0
Access: 2023-03-10 16:12:01.128572749 +0800
Modify: 2023-03-10 16:12:01.128572749 +0800
Change: 2023-03-10 16:15:00.855248561 +0800
 Birth: 2023-03-10 16:12:01.127572782 +0800
  File: SZ.soft -> /test/SZ
  Size: 12            Blocks: 0          IO Block: 4096   symbolic link
Device: fd00h/64768d    Inode: 1269701     Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:default_t:s0
Access: 2023-03-10 16:17:52.243633763 +0800
Modify: 2023-03-10 16:17:49.291727824 +0800
Change: 2023-03-10 16:17:49.291727824 +0800
 Birth: 2023-03-10 16:17:49.291727824 +0800
[root@localhost test]# echo 123 > SZ
[root@localhost test]# cat SZ SZ.hard SZ.soft
123
123
123
[root@localhost test]# echo 222 >SZ.hard
[root@localhost test]# cat SZ SZ.hard SZ.soft
222
222
222
[root@localhost test]# echo 333 >SZ.soft
[root@localhost test]# cat SZ SZ.hard SZ.soft
333
333
333
[root@localhost test]# rm SZ
rm: remove regular file 'SZ'? y
[root@localhost test]# ls
SZ.hard  SZ.soft
[root@localhost test]# ll
total 4
-rw-r--r--. 1 root root  4 Mar 10 16:30 SZ.hard
lrwxrwxrwx. 1 root root 12 Mar 10 16:17 SZ.soft -> /test/SZ
[root@localhost test]# cat  SZ.hard SZ.soft
333
cat: SZ.soft: No such file or directory
[root@localhost test]# echo 123>SZ

[root@localhost test]# ls
SZ  SZ.hard  SZ.soft
[root@localhost test]# ll
total 4
-rw-r--r--. 1 root root  0 Mar 10 16:35 SZ
-rw-r--r--. 1 root root  4 Mar 10 16:30 SZ.hard
lrwxrwxrwx. 1 root root 12 Mar 10 16:17 SZ.soft -> /test/SZ
[root@localhost test]# cat SZ SZ.hard SZ.soft
333
[root@localhost test]# cat  SZ.hard SZ.soft
333
[root@localhost test]# cat  SZ.hard 
333
[root@localhost test]# cat  SZ 
[root@localhost test]# echo 123 > SZ
[root@localhost test]# cat SZ
123
[root@localhost test]# cat SZ SZ.hard SZ.soft
123
333
123
[root@localhost test]# stat SZ SZ.hard SZ.soft
  File: SZ
  Size: 4             Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 1269705     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 16:37:46.522403060 +0800
Modify: 2023-03-10 16:37:37.348696378 +0800
Change: 2023-03-10 16:37:37.348696378 +0800
 Birth: 2023-03-10 16:35:46.928226970 +0800
  File: SZ.hard
  Size: 4             Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 1269702     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 16:33:24.906772533 +0800
Modify: 2023-03-10 16:30:43.406953464 +0800
Change: 2023-03-10 16:32:16.714955750 +0800
 Birth: 2023-03-10 16:12:01.127572782 +0800
  File: SZ.soft -> /test/SZ
  Size: 12            Blocks: 0          IO Block: 4096   symbolic link
Device: fd00h/64768d    Inode: 1269701     Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:default_t:s0
Access: 2023-03-10 16:17:52.243633763 +0800
Modify: 2023-03-10 16:17:49.291727824 +0800
Change: 2023-03-10 16:17:49.291727824 +0800
 Birth: 2023-03-10 16:17:49.291727824 +0800

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值