Linux 命令ln

在linux中可用ln命令创建一个文件的链接(软链接或者硬链接)

硬链接的使用:

root@IdeaPad:~# ln 2.txt e.txt
root@IdeaPad:~# ls
1.txt  2.txt  3.txt  4.txt  5.txt  5.txt~  e.txt  test
root@IdeaPad:~# cat 2.txt
在li上,安装软件一共有三种方式:
1.源代码安装
2.包安装
3.apt在线安装
root@IdeaPad:~# cat e.txt 
在li上,安装软件一共有三种方式:
1.源代码安装
2.包安装
3.apt在线安装
root@IdeaPad:~# 

 软链接的使用:

root@IdeaPad:~# ln -s 2.txt evilxr
root@IdeaPad:~# ls -l
total 32
-rw-r--r-- 1 root root  101  5月 29 10:03 1.txt
-rw-r--r-- 2 root root   96  5月 29 10:46 2.txt
-rw-r--r-- 1 root root  115  5月 29 10:56 3.txt
-rw-r--r-- 1 root root  181  5月 29 11:12 4.txt
-rw-r--r-- 1 root root 2717  5月 29 12:00 5.txt
-rw-r--r-- 1 root root   18  5月 29 11:51 5.txt~
-rw-r--r-- 2 root root   96  5月 29 10:46 e.txt
lrwxrwxrwx 1 root root    5  6月  2 13:01 evilxr -> 2.txt
drwxr-xr-x 2 root root 4096  5月 29 10:17 test
root@IdeaPad:~# cat evilxr
在li上,安装软件一共有三种方式:
1.源代码安装
2.包安装
3.apt在线安装
root@IdeaPad:~# 
若非特别声明,文章均为Evilxr的个人笔记,转载请注明出处。
原文地址:https://www.cnblogs.com/evilxr/p/3764253.html