作者:Jaaaaasonnv_116 | 来源:互联网 | 2023-09-13 14:50
一:文件类型以及符号表示在ls-l显示的详细信息中有以下信息:-rw-r--r--drwxr-xr-x一共10个字符,第一个字符表示文件类型,后面9个字符分成3组表示文
一:文件类型以及符号表示
在ls -l显示的详细信息中有以下信息:
-rw-r--r--
drwxr-xr-x
一共10个字符,第一个字符表示文件类型,后面9个字符分成3组表示文件权限。前三个表示属主(拥有者)对文件的权限,中间三个表示属主所在的组对文件的权限,最后三个表示其他用户对文件的权限。
文件类型:
- 表示普通文件 如:a.c,1.txt,a.out
d 表示文件夹 d是directory的缩写
l 表示符号连接文件
s 表示socket文件
p 表示管道文件 pipe
rwx解析:r代表可读,数字标号为4;w代表可写,数字标号为2;x代表可执行,数字标号为1。
二:创建目录
[[email protected] ~]# mkdir /root/test
[[email protected] ~]# ll
total 8
-rw-------. 1 root root 1701 Nov 2 06:06 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Desktop
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Documents
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Downloads
-rw-r--r--. 1 root root 1856 Nov 2 06:08 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Music
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Pictures
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Public
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Templates
drwxr-xr-x. 2 root root 6 Nov 13 19:48 test
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Videos
[[email protected] ~]# cd /root/test/
三:在text目录下用两种方式创建test1.txt,test2.txt
[[email protected] test]# vim text1.txt
[[email protected] test]# mkdir text2.txt
[[email protected] test]# ll
total 4
-rw-r--r--. 1 root root 37 Nov 13 19:59 text1.txt
drwxr-xr-x. 2 root root 6 Nov 13 20:03 text2.txt
[[email protected] test]# vim text1.txt
text1:
四:将test文件拷贝到test2目录
[[email protected] ~]# cp -r /root/test /root/test/text2.txt
total 8
-rw-------. 1 root root 1701 Nov 2 06:06 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Desktop
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Documents
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Downloads
-rw-r--r--. 1 root root 1856 Nov 2 06:08 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Music
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Pictures
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Public
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Templates
drwxr-xr-x. 3 root root 40 Nov 13 20:10 test
drwxr-xr-x. 3 root root 40 Nov 13 20:18 test2
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Videos
[[email protected] ~]# cd test2/
[[email protected] test2]# ll
total 4
-rw-r--r--. 1 root root 78 Nov 13 20:18 text1.txt
drwxr-xr-x. 4 root root 52 Nov 13 20:18 text2.txt
五:将text2中的text1.txt重命名为text111.txt
[[email protected] test2]# ll
total 4
-rw-r--r--. 1 root root 78 Nov 13 20:18 text1.txt
drwxr-xr-x. 4 root root 52 Nov 13 20:18 text2.txt
-rw-r--r--. 1 root root 0 Nov 13 20:24 text3,txt
[[email protected] test2]# mv text1.txt text111.txt
[[email protected] test2]# ll
total 4
-rw-r--r--. 1 root root 78 Nov 13 20:18 text111.txt
drwxr-xr-x. 4 root root 52 Nov 13 20:18 text2.txt
-rw-r--r--. 1 root root 0 Nov 13 20:24 text3,txt
六:在test2目录中新建test111.txt的软链接文件test111_soft.txt
[[email protected] test2]# ln -s text111.txt test111_soft.txt
[[email protected] test2]# ll
total 4
lrwxrwxrwx. 1 root root 11 Nov 13 20:32 test111_soft.txt -> text111.txt
-rw-r--r--. 1 root root 78 Nov 13 20:18 text111.txt
drwxr-xr-x. 4 root root 52 Nov 13 20:18 text2.txt
-rw-r--r--. 1 root root 0 Nov 13 20:24 text3,txt
七:在test2目录中新建test111.txt的硬链接文件test111_hard.txt
[[email protected] test2]# ln text111.txt test111_hard.txt
[[email protected] test2]# ll
total 8
-rw-r--r--. 2 root root 78 Nov 13 20:18 test111_hard.txt
lrwxrwxrwx. 1 root root 11 Nov 13 20:32 test111_soft.txt -> text111.txt
-rw-r--r--. 2 root root 78 Nov 13 20:18 text111.txt
drwxr-xr-x. 4 root root 52 Nov 13 20:18 text2.txt
-rw-r--r--. 1 root root 0 Nov 13 20:24 text3,txt
八:删除test目录中test1.txt
[[email protected] ~]# cd /root/test/
[[email protected] test]# ll
total 4
-rw-r--r--. 1 root root 78 Nov 13 20:04 text1.txt
drwxr-xr-x. 4 root root 52 Nov 13 20:17 text2.txt
[[email protected] test]# ll
total 4
-rw-r--r--. 1 root root 78 Nov 13 20:04 text1.txt
drwxr-xr-x. 4 root root 52 Nov 13 20:17 text2.txt
[[email protected] test]# rm -f text1.txt
[[email protected] test]# ll
total 0
drwxr-xr-x. 4 root root 52 Nov 13 20:17 text2.txt
九:删除test目录
[[email protected] ~]# ll
total 8
-rw-------. 1 root root 1701 Nov 2 06:06 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Desktop
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Documents
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Downloads
-rw-r--r--. 1 root root 1856 Nov 2 06:08 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Music
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Pictures
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Public
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Templates
drwxr-xr-x. 3 root root 23 Nov 13 20:42 test
drwxr-xr-x. 3 root root 107 Nov 13 20:35 test2
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Videos
[[email protected] ~]# rm -r -f test
[[email protected] ~]# ll
total 8
-rw-------. 1 root root 1701 Nov 2 06:06 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Desktop
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Documents
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Downloads
-rw-r--r--. 1 root root 1856 Nov 2 06:08 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Music
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Pictures
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Public
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Templates
drwxr-xr-x. 3 root root 107 Nov 13 20:35 test2
drwxr-xr-x. 2 root root 6 Nov 2 06:10 Videos