linux 软硬链接以及其他操作

[C:\~]$ ssh 192.168.137.129


Connecting to 192.168.137.129: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
/usr/bin/xauth:  file /root/.Xauthority does not exist
[root@localhost ~]# mkdir test
[root@localhost ~]# ls
anaconda-ks.cfg  test
[root@localhost ~]#  cd /~
-bash: cd: /~: No such file or directory
[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]# touch a
[root@localhost test]# la
bash: la: command not found...
[root@localhost test]# ls
a
[root@localhost test]# ln a
ln: failed to create hard link './a': File exists
[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]# ls
a  a.hard  a.soft
[root@localhost test]# ll
total 0
-rw-r--r--. 2 root root 0 Mar  9 08:18 a
-rw-r--r--. 2 root root 0 Mar  9 08:18 a.hard
lrwxrwxrwx. 1 root root 7 Mar  9 08:21 a.soft -> /test/a
[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.hard  a.soft
[root@localhost test]# ll
total 4
-rw-r--r--. 1 root root 4 Mar  9 08:24 a.hard
lrwxrwxrwx. 1 root root 7 Mar  9 08:21 a.soft -> /test/a
[root@localhost test]# cat a a.hard a.soft
cat: a: No such file or directory
333
cat: a.soft: No such file or directory
[root@localhost test]# echo 123 > a
[root@localhost test]# ls
a  a.hard  a.soft
[root@localhost test]# ll
total 8
-rw-r--r--. 1 root root 4 Mar  9 08:26 a
-rw-r--r--. 1 root root 4 Mar  9 08:24 a.hard
lrwxrwxrwx. 1 root root 7 Mar  9 08:21 a.soft -> /test/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 file
Device: fd00h/64768d    Inode: 34989256    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:default_t:s0
Access: 2023-03-09 08:26:39.811342324 -0500
Modify: 2023-03-09 08:26:27.195407173 -0500
Change: 2023-03-09 08:26:27.195407173 -0500
 Birth: 2023-03-09 08:26:27.195407173 -0500
  File: a.hard
  Size: 4             Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 34989254    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:default_t:s0
Access: 2023-03-09 08:25:54.514605784 -0500
Modify: 2023-03-09 08:24:59.403959632 -0500
Change: 2023-03-09 08:25:37.889712230 -0500
 Birth: 2023-03-09 08:18:11.548982180 -0500
  File: a.soft -> /test/a
  Size: 7             Blocks: 0          IO Block: 4096   symbolic link
Device: fd00h/64768d    Inode: 34989255    Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:default_t:s0
Access: 2023-03-09 08:21:38.077064993 -0500
Modify: 2023-03-09 08:21:35.903081697 -0500
Change: 2023-03-09 08:21:35.903081697 -0500
 Birth: 2023-03-09 08:21:35.903081697 -0500
[root@localhost test]# 

以上操作包括软硬链接以及文件之间的区别

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不会取名余

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值