拷贝文件夹
cp -a 原文件路径 新文件路径
例如:
cp -a ./a/b/ ./b
建立链接文件:ln
类似Windows中的建立快捷方式
[ck153117137@shell.ceshiren.com ~]$ ln -s ./a/b/ ./c # 把a文件下的b文件 建立快捷方式到当前文件夹的c
[ck153117137@shell.ceshiren.com ~]$ ls
a b c nginx.log Python-3.9.0.tar.xz test01.txt
[ck153117137@shell.ceshiren.com ~]$ ls -l
total 428
drwxrwxr-x 3 ck153117137 ck153117137 4096 Oct 11 13:01 a
drwxrwxr-x 3 ck153117137 ck153117137 4096 Oct 11 13:02 b
lrwxrwxrwx 1 ck153117137 ck153117137 6 Oct 11 15:12 c -> ./a/b/ # c指向的是a文件夹下的b文件
-rw-r--r-- 1 ck153117137 ck153117137 424573 Sep 7 22:07 nginx.log
-rw-rw-r-- 1 ck153117137 ck153117137 0 Oct 10 16:39 Python-3.9.0.tar.xz
-rw-rw-r-- 1 ck153117137 ck153117137 50 Sep 8 22:58 test01.txt
## 当我们进入c文件夹 创建了1.txt的时候,我们进入./a/b文件夹中查看文件也会有1.txt,并且内容一致
[ck153117137@shell.ceshiren.com ~]$ cd c
[ck153117137@shell.ceshiren.com c]$ ls
[ck153117137@shell.ceshiren.com c]$ vim 1.txt
[ck153117137@shell.ceshiren.com ~]$ cd a
[ck153117137@shell.ceshiren.com a]$ ls
b Python-3.9.0.tar.xz
[ck153117137@shell.ceshiren.com a]$ cd b
[ck153117137@shell.ceshiren.com b]$ ls
1.txt
[ck153117137@shell.ceshiren.com b]$ cat 1.txt
qwq
# 删掉链接文件b后,快捷方式c文件会变成红色
[ck153117137@shell.ceshiren.com a]$ rm -rf b
![image.png](https://upload-images.jianshu.io/upload_images/19724232-daed1c58f89bacfd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![image.png](https://upload-images.jianshu.io/upload_images/19724232-dc2a3ef067d3a26d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)