1.权限归属
读: read
写: write
可执行: excute
#################
[root@room9pc01 ~]# ls -ld /etc/passwd /boot
dr-xr-xr-x. 6 root root 4096 1月 1 04:09 /boot
-rw-r–r-- 1 root root 2416 3月 30 17:39 /etc/passwd
#######
chmod 权限
chmod ±= [rwx] 文件
[root@room9pc01 ~]# vim test01.sh
[root@room9pc01 ~]# chmod +x test01.sh
[root@room9pc01 ~]# ls
abc jdk-8u201-linux-x64.tar.gz setip test07.sh 视频 音乐
anaconda-ks.cfg jdk-8u231-linux-x64.tar.gz *test01.sh*
test08.sh 图片 桌面
bin original-ks.cfg test04.sh 公共 文档
debian-binary PycharmProjects test06.sh 模板 下载
[root@room9pc01 ~]# chmod -x test01.sh
[root@room9pc01 ~]# ls
abc jdk-8u201-linux-x64.tar.gz setip test07.sh 视频 音乐
anaconda-ks.cfg jdk-8u231-linux-x64.tar.gz test01.sh test08.sh 图片 桌面
bin original-ks.cfg test04.sh 公共 文档
debian-binary PycharmProjects test06.sh 模板 下载
[root@room9pc01 ~]# chmod =x test01.sh
[root@room9pc01 ~]# ls
abc jdk-8u201-linux-x64.tar.gz setip test07.sh 视频 音乐
anaconda-ks.cfg jdk-8u231-linux-x64.tar.gz test01.sh test08.sh 图片 桌面
bin original-ks.cfg test04.sh 公共 文档
debian-binary PycharmProjects test06.sh 模板 下载
[root@room9pc01 ~]# chmod =x test01.sh
[root@room9pc01 ~]# ls
abc jdk-8u201-linux-x64.tar.gz setip test07.sh 视频 音乐
anaconda-ks.cfg jdk-8u231-linux-x64.tar.gz test01.sh test08.sh 图片 桌面
bin original-ks.cfg test04.sh 公共 文档
debian-binary PycharmProjects test06.sh 模板 下载
############
权限数字方式表示;’
421
chmod 755 /nsd1
[root@room9pc01 ~]# ls -ld /nsd1
drwxr-xr-x 2 root root 4096 3月 30 19:14 /nsd1
###########################
文件目录的默认权限
默认: 目录的权限:755 文件的权限: 644
umask
0022 777-022 =755 666-022= 644
[root@room9pc01 ~]# umask 077
[root@room9pc01 ~]# umask
0077
[root@room9pc01 ~]# mkdir /nsd15
[root@room9pc01 ~]# ls -ld /nsd15
drwx------ 2 root root 4096 3月 31 10:45 /nsd15
[root@room9pc01 ~]# umask 022
############################################
改变归属关系: chown
chown lisi /nsd1
[root@room9pc01 ~]# chown lisi /nsd1
[root@room9pc01 ~]# ls -ld /nsd1
drwxr-xr-x 2 lisi root 4096 3月 30 19:14 /nsd1
chown lisi:mn /nsd2 (lisi为所有者)
############################################
附加权限
s / S
[root@room9pc01 ~]# mkdir /nsd21
[root@room9pc01 ~]# ls -ld /nsd21
drwxr-xr-x 2 root root 4096 3月 31 11:10 /nsd21
[root@room9pc01 ~]# chmod g+s /nsd21
[root@room9pc01 ~]# ls -ld /nsd21
drwxr-sr-x 2 root root 4096 3月 31 11:10 /nsd21
[root@room9pc01 ~]# chmod g-x /nsd21
[root@room9pc01 ~]# ls -ld /nsd21 (不具备执行权限)
drwxr-Sr-x 2 root root 4096 3月 31 11:10 /nsd21 (大写)
#########
sticky bit 粘滞位 t 权限
t / T(没有执行权限)
使得 其他人无法对自己的文档进行写入和删除
[root@room9pc01 ~]# mkdir /home/public
[root@room9pc01 ~]# cd /home/public
[root@room9pc01 public]# chmod +t /public
[root@room9pc01 public]# ls -ld /public
drwxr-xr-t. 2 root root 4096 3月 5 2019 /public
###############
setfacl 命令
格式: setfacl -m|x|b|R u:用户名 : 权限 文件
m 定义一条ACl
x 清除指定 ACL
b 清除所有的ACL
R 递归设置ACL
getfacl : 查看权限.更加详细
[root@room9pc01 ~]# getfacl /etc/shadow
getfacl: Removing leading ‘/’ from absolute path names
file: etc/shadow # owner: root
group: root
user::—
user:lisi:r–
group::—
mask::r–
other::