[root@localhost ~]# ls -l
总用量 8
-rw-r--r-- 1 root root 12 7月 31 21:38 1.txt
-rw-r--r-- 1 root root 0 7月 30 22:34 22.txt
-rw-r--r-- 1 root root 0 7月 30 22:31 2.txt
-rw-------. 1 root root 1430 7月 12 10:41 anaconda-ks.cfg
u为用户 g为组 o为其他人 a为所有u+g+o
r=4 w=2 x=1 rwx=7 rw-=6 r-x=5
[root@localhost ~]# ls -l 1.txt
-rwxrwxrwx 1 root root 12 7月 31 21:38 1.txt
[root@localhost ~]# chmod 600 1.txt
[root@localhost ~]# ls -l 1.txt
-rw------- 1 root root 12 7月 31 21:38 1.txt
[root@localhost ~]# chmod a+x,u+w,g+r,o+w 1.txt
[root@localhost ~]# ls -l 1.txt
-rwxr-x-wx 1 root root 12 7月 31 21:38 1.txt
[root@localhost ~]# chmod u=r,g=rwx,o=wx 1.txt
[root@localhost ~]# ls -l 1.txt
-r--rwx-wx 1 root root 12 7月 31 21:38 1.txt
介绍:查看和更改默认权限
, 默认0022(一般用后3位)
root 有最高权限不受此影响 ,所以目录为rwxrwxrwx - ----w--w- = rwxr-xr-x(有x权限才能进入)
文件为rw-rw-rw- - ----w-w- = rw-r--r--
[root@localhost ~]# touch 1.txt
[root@localhost ~]# ls -l
总用量 4
-rw-r--r-- 1 root root 0 7月 31 22:25 1.txt
-rw-------. 1 root root 1430 7月 12 10:41 anaconda-ks.cfg
[root@localhost ~]# umask 0111
[root@localhost ~]# touch 2.txt
[root@localhost ~]# ls -l
总用量 4
-rw-r--r-- 1 root root 0 7月 31 22:25 1.txt
-rw-rw-rw- 1 root root 0 7月 31 22:26 2.txt
-rw-------. 1 root root 1430 7月 12 10:41 anaconda-ks.cfg
[root@localhost ~]# umask 0222
[root@localhost ~]# touch 3.txt
[root@localhost ~]# ls -l
总用量 4
-rw-r--r-- 1 root root 0 7月 31 22:25 1.txt
-rw-rw-rw- 1 root root 0 7月 31 22:26 2.txt
-r--r--r-- 1 root root 0 7月 31 22:26 3.txt
-rw-------. 1 root root 1430 7月 12 10:41 anaconda-ks.cfg
[root@localhost ~]# ls -l
总用量 4
-rw-------. 1 ping ping 1430 7月 12 10:41 anaconda-ks.cfg
[root@localhost ~]# chown root: anaconda-ks.cfg
[root@localhost ~]# ls -l
总用量 4
-rw-------. 1 root root 1430 7月 12 10:41 anaconda-ks.cfg
[root@localhost ~]# chown ping:root anaconda-ks.cfg
[root@localhost ~]# ls -l
总用量 4
-rw-------. 1 ping root 1430 7月 12 10:41 anaconda-ks.cfg
[root@localhost ~]# chown :ping anaconda-ks.cfg
[root@localhost ~]# ls -l
总用量 4
-rw-------. 1 ping ping 1430 7月 12 10:41 anaconda-ks.cfg
[root@localhost ~]# chown -R root:root ./
[root@localhost ~]# ls -l
总用量 4
-rw-------. 1 root root 1430 7月 12 10:41 anaconda-ks.cfg
!命令标号 : 可直接执行编号的命令
。!ch : 执行最近ch开头的命令
[root@localhost ~]# history | tail -2
250 history
251 history | tail -2
[root@localhost ~]# history | tail -4
249 ls -l
250 history
251 history | tail -2
252 history | tail -4
[root@localhost ~]# !249
ls -l
总用量 4
-rw-------. 1 root root 1430 7月 12 10:41 anaconda-ks.cfg