2022052410软连接

该文本展示了在Linux环境中使用mv命令移动文件到/usr/lib目录,使用cp命令复制文件到mydir目录,以及创建软链接(link)的操作。在过程中,遇到了cd命令尝试进入符号链接目录但失败,以及正确删除链接文件的问题。
摘要由CSDN通过智能技术生成

[root@hadoop100 ~]# mv a.txt aaa.txt
[root@hadoop100 ~]# ll
总用量 976
-rw-r–r–. 1 root root 0 6月 4 07:49 1.txt
-rw-r–r–. 1 root root 947476 6月 4 08:41 aaa.txt
-rw-------. 1 root root 1683 5月 29 23:54 anaconda-ks.cfg
-rw-r–r–. 1 root root 1731 5月 30 00:10 initial-setup-ks.cfg
-rw-r–r–. 1 root root 0 6月 3 12:45 my.txt
drwxr-xr-x. 2 root root 4096 6月 3 12:46 test
drwxr-xr-x. 2 root root 4096 5月 30 00:42 公共
drwxr-xr-x. 4 root root 4096 6月 3 12:16 机器人
drwxr-xr-x. 2 root root 4096 5月 30 00:42 模板
drwxr-xr-x. 2 root root 4096 5月 30 00:42 视频
drwxr-xr-x. 2 root root 4096 5月 30 00:42 图片
drwxr-xr-x. 2 root root 4096 5月 30 00:42 文档
drwxr-xr-x. 2 root root 4096 5月 30 00:42 下载
drwxr-xr-x. 2 root root 4096 5月 30 00:42 音乐
drwxr-xr-x. 2 root root 4096 5月 30 00:42 桌面
[root@hadoop100 ~]# mv aaa.txt /usr/lib/newaaa.txt
[root@hadoop100 ~]# cd /usr/lib
[root@hadoop100 lib]# ll
总用量 1112
drwxr-xr-x. 3 root root 4096 5月 29 23:49 alsa
drwxr-xr-x. 2 root root 4096 10月 2 2020 binfmt.d
drwxr-xr-x. 3 root root 4096 5月 29 23:50 crda
drwxr-xr-x. 9 root root 4096 5月 29 23:48 cups
drwxr-xr-x. 3 root root 4096 4月 11 2018 debug
drwxr-xr-x. 4 root root 4096 5月 29 23:47 dracut
drwxr-xr-x. 7 root root 4096 5月 29 23:49 firewalld
drwxr-xr-x. 91 root root 20480 5月 29 23:50 firmware
drwxr-xr-x. 3 root root 4096 5月 29 23:46 fontconfig
dr-xr-xr-x. 2 root root 4096 4月 11 2018 games
drwxr-xr-x. 3 root root 4096 5月 29 23:46 grub
drwxr-xr-x. 2 root root 4096 11月 21 2015 java
drwxr-xr-x. 2 root root 4096 11月 21 2015 java-1.5.0
drwxr-xr-x. 2 root root 4096 11月 21 2015 java-1.6.0
drwxr-xr-x. 2 root root 4096 11月 21 2015 java-1.7.0
drwxr-xr-x. 2 root root 4096 11月 21 2015 java-1.8.0
drwxr-xr-x. 2 root root 4096 11月 21 2015 java-ext
drwxr-xr-x. 4 root root 4096 5月 29 23:48 jvm
drwxr-xr-x. 2 root root 4096 11月 21 2015 jvm-commmon
drwxr-xr-x. 4 root root 4096 5月 29 23:48 jvm-exports
drwxr-xr-x. 5 root root 4096 5月 29 23:47 jvm-private
drwxr-xr-x. 6 root root 4096 5月 29 23:46 kbd
drwxr-xr-x. 2 root root 4096 5月 29 23:47 kdump
drwxr-xr-x. 3 root root 4096 10月 2 2020 kernel
drwxr-xr-x. 2 root root 4096 5月 29 23:46 locale
drwxr-xr-x. 2 root root 4096 5月 29 23:47 modprobe.d
drwxr-xr-x. 3 root root 4096 5月 29 23:47 modules
drwxr-xr-x. 2 root root 4096 5月 29 23:47 modules-load.d
drwxr-xr-x. 4 root root 4096 5月 29 23:46 mozilla
drwxr-xr-x. 4 root root 4096 5月 29 23:47 NetworkManager
-rw-r–r–. 1 root root 947476 6月 4 08:41 newaaa.txt
-rw-r–r–. 1 root root 393 10月 23 2020 os-release
drwxr-xr-x. 2 root root 4096 5月 29 23:47 polkit-1
drwxr-xr-x. 3 root root 4096 5月 29 23:46 python2.7
drwxr-xr-x. 5 root root 4096 5月 29 23:48 rpm
lrwxrwxrwx. 1 root root 30 5月 29 23:50 sendmail -> /etc/alternatives/mta-sendmail
lrwxrwxrwx. 1 root root 24 5月 29 23:50 sendmail.postfix -> …/sbin/sendmail.postfix
dr-xr-xr-x. 2 root root 4096 4月 11 2018 sse2
drwxr-xr-x. 2 root root 4096 5月 29 23:49 sysctl.d
drwxr-xr-x. 13 root root 4096 5月 29 23:49 systemd
drwxr-xr-x. 2 root root 4096 5月 29 23:50 tmpfiles.d
drwxr-xr-x. 13 root root 4096 5月 29 23:49 tuned
drwxr-xr-x. 4 root root 4096 5月 29 23:50 udev
drwxr-xr-x. 2 root root 4096 5月 29 23:50 yum-plugins
drwxr-xr-x. 4 root root 4096 6月 3 12:23 机器人
[root@hadoop100 lib]# cd ~
[root@hadoop100 ~]# ll
总用量 48
-rw-r–r–. 1 root root 0 6月 4 07:49 1.txt
-rw-------. 1 root root 1683 5月 29 23:54 anaconda-ks.cfg
-rw-r–r–. 1 root root 1731 5月 30 00:10 initial-setup-ks.cfg
-rw-r–r–. 1 root root 0 6月 3 12:45 my.txt
drwxr-xr-x. 2 root root 4096 6月 3 12:46 test
drwxr-xr-x. 2 root root 4096 5月 30 00:42 公共
drwxr-xr-x. 4 root root 4096 6月 3 12:16 机器人
drwxr-xr-x. 2 root root 4096 5月 30 00:42 模板
drwxr-xr-x. 2 root root 4096 5月 30 00:42 视频
drwxr-xr-x. 2 root root 4096 5月 30 00:42 图片
drwxr-xr-x. 2 root root 4096 5月 30 00:42 文档
drwxr-xr-x. 2 root root 4096 5月 30 00:42 下载
drwxr-xr-x. 2 root root 4096 5月 30 00:42 音乐
drwxr-xr-x. 2 root root 4096 5月 30 00:42 桌面
[root@hadoop100 ~]# mkdir mydir
[root@hadoop100 ~]# cp 1.txt mydir
[root@hadoop100 ~]# cp my.txt mydir
[root@hadoop100 ~]# cd mydir
[root@hadoop100 mydir]# ll
总用量 0
-rw-r–r–. 1 root root 0 6月 4 08:55 1.txt
-rw-r–r–. 1 root root 0 6月 4 08:56 my.txt
[root@hadoop100 mydir]# ln -s mydir linkmydie
[root@hadoop100 mydir]# ll
总用量 0
-rw-r–r–. 1 root root 0 6月 4 08:55 1.txt
lrwxrwxrwx. 1 root root 5 6月 4 08:58 linkmydie -> mydir
-rw-r–r–. 1 root root 0 6月 4 08:56 my.txt
[root@hadoop100 mydir]# ln -s mydir linkmydir
[root@hadoop100 mydir]# ll
总用量 0
-rw-r–r–. 1 root root 0 6月 4 08:55 1.txt
lrwxrwxrwx. 1 root root 5 6月 4 08:58 linkmydie -> mydir
lrwxrwxrwx. 1 root root 5 6月 4 09:01 linkmydir -> mydir
-rw-r–r–. 1 root root 0 6月 4 08:56 my.txt
[root@hadoop100 mydir]# cd linkmydir
-bash: cd: linkmydir: 没有那个文件或目录
[root@hadoop100 mydir]# ll
总用量 0
-rw-r–r–. 1 root root 0 6月 4 08:55 1.txt
lrwxrwxrwx. 1 root root 5 6月 4 08:58 linkmydie -> mydir
lrwxrwxrwx. 1 root root 5 6月 4 09:01 linkmydir -> mydir
-rw-r–r–. 1 root root 0 6月 4 08:56 my.txt
[root@hadoop100 mydir]# rm linkmydie
rm:是否删除符号链接 “linkmydie”?
[root@hadoop100 mydir]# ll
总用量 0
-rw-r–r–. 1 root root 0 6月 4 08:55 1.txt
lrwxrwxrwx. 1 root root 5 6月 4 08:58 linkmydie -> mydir
lrwxrwxrwx. 1 root root 5 6月 4 09:01 linkmydir -> mydir
-rw-r–r–. 1 root root 0 6月 4 08:56 my.txt
[root@hadoop100 mydir]# rm linkmydie
rm:是否删除符号链接 “linkmydie”?y
[root@hadoop100 mydir]# ll
总用量 0
-rw-r–r–. 1 root root 0 6月 4 08:55 1.txt
lrwxrwxrwx. 1 root root 5 6月 4 09:01 linkmydir -> mydir
-rw-r–r–. 1 root root 0 6月 4 08:56 my.txt
[root@hadoop100 mydir]# cd lingmydir
-bash: cd: lingmydir: 没有那个文件或目录
[root@hadoop100 mydir]# ll
总用量 0
-rw-r–r–. 1 root root 0 6月 4 08:55 1.txt
lrwxrwxrwx. 1 root root 5 6月 4 09:01 linkmydir -> mydir
-rw-r–r–. 1 root root 0 6月 4 08:56 my.txt
[root@hadoop100 mydir]# linkmydir
bash: linkmydir: 未找到命令…
[root@hadoop100 mydir]# cd…
bash: cd…: 未找到命令…
[root@hadoop100 mydir]# cd …
[root@hadoop100 ~]# ll
总用量 52
-rw-r–r–. 1 root root 0 6月 4 07:49 1.txt
-rw-------. 1 root root 1683 5月 29 23:54 anaconda-ks.cfg
-rw-r–r–. 1 root root 1731 5月 30 00:10 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 4096 6月 4 09:03 mydir
-rw-r–r–. 1 root root 0 6月 3 12:45 my.txt
drwxr-xr-x. 2 root root 4096 6月 3 12:46 test
drwxr-xr-x. 2 root root 4096 5月 30 00:42 公共
drwxr-xr-x. 4 root root 4096 6月 3 12:16 机器人
drwxr-xr-x. 2 root root 4096 5月 30 00:42 模板
drwxr-xr-x. 2 root root 4096 5月 30 00:42 视频
drwxr-xr-x. 2 root root 4096 5月 30 00:42 图片
drwxr-xr-x. 2 root root 4096 5月 30 00:42 文档
drwxr-xr-x. 2 root root 4096 5月 30 00:42 下载
drwxr-xr-x. 2 root root 4096 5月 30 00:42 音乐
drwxr-xr-x. 2 root root 4096 5月 30 00:42 桌面
[root@hadoop100 ~]# ln -s mydir linkmydir
[root@hadoop100 ~]# ll
总用量 52
-rw-r–r–. 1 root root 0 6月 4 07:49 1.txt
-rw-------. 1 root root 1683 5月 29 23:54 anaconda-ks.cfg
-rw-r–r–. 1 root root 1731 5月 30 00:10 initial-setup-ks.cfg
lrwxrwxrwx. 1 root root 5 6月 4 09:07 linkmydir -> mydir
drwxr-xr-x. 2 root root 4096 6月 4 09:03 mydir
-rw-r–r–. 1 root root 0 6月 3 12:45 my.txt
drwxr-xr-x. 2 root root 4096 6月 3 12:46 test
drwxr-xr-x. 2 root root 4096 5月 30 00:42 公共
drwxr-xr-x. 4 root root 4096 6月 3 12:16 机器人
drwxr-xr-x. 2 root root 4096 5月 30 00:42 模板
drwxr-xr-x. 2 root root 4096 5月 30 00:42 视频
drwxr-xr-x. 2 root root 4096 5月 30 00:42 图片
drwxr-xr-x. 2 root root 4096 5月 30 00:42 文档
drwxr-xr-x. 2 root root 4096 5月 30 00:42 下载
drwxr-xr-x. 2 root root 4096 5月 30 00:42 音乐
drwxr-xr-x. 2 root root 4096 5月 30 00:42 桌面
[root@hadoop100 ~]# cd linkmydir
[root@hadoop100 linkmydir]# ll
总用量 0
-rw-r–r–. 1 root root 0 6月 4 08:55 1.txt
lrwxrwxrwx. 1 root root 5 6月 4 09:01 linkmydir -> mydir
-rw-r–r–. 1 root root 0 6月 4 08:56 my.txt
[root@hadoop100 linkmydir]# cd ~
[root@hadoop100 ~]# cd mydir
[root@hadoop100 mydir]# vm 2.txt
bash: vm: 未找到命令…
相似命令是: ‘mv’
[root@hadoop100 mydir]# vim 2.txt
[root@hadoop100 mydir]# cd…
bash: cd…: 未找到命令…
[root@hadoop100 mydir]# cd …
[root@hadoop100 ~]# cd linkdir
-bash: cd: linkdir: 没有那个文件或目录
[root@hadoop100 ~]# cd linkmydir
[root@hadoop100 linkmydir]# ll
总用量 4
-rw-r–r–. 1 root root 0 6月 4 08:55 1.txt
-rw-r–r–. 1 root root 67 6月 4 09:12 2.txt
lrwxrwxrwx. 1 root root 5 6月 4 09:01 linkmydir -> mydir
-rw-r–r–. 1 root root 0 6月 4 08:56 my.txt
[root@hadoop100 linkmydir]# cat 2.txt
vfhsdijjvnvjf
dddjjdjjf
fff
jjjjjjjj2023年6月4日大数据启动
[root@hadoop100 linkmydir]# cd …
[root@hadoop100 ~]# rm rf linkmydir
rm: 无法删除"rf": 没有那个文件或目录
rm:是否删除符号链接 “linkmydir”?rm -rf linjHkHHHHH^Hy
[root@hadoop100 ~]# ll
总用量 52
-rw-r–r–. 1 root root 0 6月 4 07:49 1.txt
-rw-------. 1 root root 1683 5月 29 23:54 anaconda-ks.cfg
-rw-r–r–. 1 root root 1731 5月 30 00:10 initial-setup-ks.cfg
lrwxrwxrwx. 1 root root 5 6月 4 09:07 linkmydir -> mydir
drwxr-xr-x. 2 root root 4096 6月 4 09:12 mydir
-rw-r–r–. 1 root root 0 6月 3 12:45 my.txt
drwxr-xr-x. 2 root root 4096 6月 3 12:46 test
drwxr-xr-x. 2 root root 4096 5月 30 00:42 公共
drwxr-xr-x. 4 root root 4096 6月 3 12:16 机器人
drwxr-xr-x. 2 root root 4096 5月 30 00:42 模板
drwxr-xr-x. 2 root root 4096 5月 30 00:42 视频
drwxr-xr-x. 2 root root 4096 5月 30 00:42 图片
drwxr-xr-x. 2 root root 4096 5月 30 00:42 文档
drwxr-xr-x. 2 root root 4096 5月 30 00:42 下载
drwxr-xr-x. 2 root root 4096 5月 30 00:42 音乐
drwxr-xr-x. 2 root root 4096 5月 30 00:42 桌面
[root@hadoop100 ~]# rm -rf linkmydir
[root@hadoop100 ~]# ll
总用量 52
-rw-r–r–. 1 root root 0 6月 4 07:49 1.txt
-rw-------. 1 root root 1683 5月 29 23:54 anaconda-ks.cfg
-rw-r–r–. 1 root root 1731 5月 30 00:10 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 4096 6月 4 09:12 mydir
-rw-r–r–. 1 root root 0 6月 3 12:45 my.txt
drwxr-xr-x. 2 root root 4096 6月 3 12:46 test
drwxr-xr-x. 2 root root 4096 5月 30 00:42 公共
drwxr-xr-x. 4 root root 4096 6月 3 12:16 机器人
drwxr-xr-x. 2 root root 4096 5月 30 00:42 模板
drwxr-xr-x. 2 root root 4096 5月 30 00:42 视频
drwxr-xr-x. 2 root root 4096 5月 30 00:42 图片
drwxr-xr-x. 2 root root 4096 5月 30 00:42 文档
drwxr-xr-x. 2 root root 4096 5月 30 00:42 下载
drwxr-xr-x. 2 root root 4096 5月 30 00:42 音乐
drwxr-xr-x. 2 root root 4096 5月 30 00:42 桌面
[root@hadoop100 ~]# ^C
[root@hadoop100 ~]# ^C
[root@hadoop100 ~]# ll
总用量 52
-rw-r–r–. 1 root root 0 6月 4 07:49 1.txt
-rw-------. 1 root root 1683 5月 29 23:54 anaconda-ks.cfg
-rw-r–r–. 1 root root 1731 5月 30 00:10 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 4096 6月 4 09:12 mydir
-rw-r–r–. 1 root root 0 6月 3 12:45 my.txt
drwxr-xr-x. 2 root root 4096 6月 3 12:46 test
drwxr-xr-x. 2 root root 4096 5月 30 00:42 公共
drwxr-xr-x. 4 root root 4096 6月 3 12:16 机器人
drwxr-xr-x. 2 root root 4096 5月 30 00:42 模板
drwxr-xr-x. 2 root root 4096 5月 30 00:42 视频
drwxr-xr-x. 2 root root 4096 5月 30 00:42 图片
drwxr-xr-x. 2 root root 4096 5月 30 00:42 文档
drwxr-xr-x. 2 root root 4096 5月 30 00:42 下载
drwxr-xr-x. 2 root root 4096 5月 30 00:42 音乐
drwxr-xr-x. 2 root root 4096 5月 30 00:42 桌面

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值