3、linux命令-权限管理
文件属性
[root@eric ~]# ll
total 153936
-rw-r-----. 1 root root 0 Jul 31 16:51 123.txt
-rw-------. 1 root root 1759 Mar 24 16:51 anaconda-ks.cfg
-rw-------. 1 root root 5222400 Jul 24 23:13 core.2366
当为 d 则是目录;
当为 - 则是文件;
若是 l 则表示为链接文档(link file);
若是 b 则表示为装置文件里面的可供储存的接口设备(可随机存取装置);
若是 c 则表示为装置文件里面的串行端口设备,例如键盘、鼠标(一次性读取装置)。
r - read 读权限
w - write 写权限
x - exec 执行权限
s 当文件被执行时,把该文件的UID或GID赋予执行进程的UID(用户ID)或GID(组 ID)。
t 设置标志位(sticky bit)。如果是有sticky bit的目录,在该目录下任何用户只要有适当的权限即可创建文
件,但文件只能被超级用户、目录拥有者或文件属主删除。如果是有sticky bit的可执行文件,在该文件执行后, 指向其正文段的指针仍留在内存。这样再次执行它时,系统就能更快地装入该文件。
- 没有相应位置的权限。
linux命令-权限管理
1.系统权限
2.服务权限
3.防火墙firewall权限
4.SElinux权限
系统权限
普通系统权限
特殊系统权限
默认系统权限
特殊ACL权限
chmod
chmod [who] [+|-|=] [mode] 文件名
[root@eric ~]# chmod --help
Usage: chmod [OPTION]... MODE[,MODE]... FILE...
or: chmod [OPTION]... OCTAL-MODE FILE...
or: chmod [OPTION]... --reference=RFILE FILE...
Change the mode of each FILE to MODE.
With --reference, change the mode of each FILE to that of RFILE.
-c, --changes like verbose but report only when a change is made
-f, --silent, --quiet suppress most error messages
-v, --verbose output a diagnostic for every file processed
--no-preserve-root do not treat '/' specially (the default)
--preserve-root fail to operate recursively on '/'
--reference=RFILE use RFILE's mode instead of MODE values
-R, --recursive change files and directories recursively
--help display this help and exit
--version output version information and exit
Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'chmod invocation'
chmod [修改的权限] [文件/目录]
u 修改文件拥有者权限
g 修改文件所属组权限
o 修改文件其他人权限
a 所有
+ 添加某个权限
- 删除某个权限
= 赋予某个权限
chmod u+x 123.txt # 为文件拥有者添加执行权限
chmod g+x 123.txt # 为文件所属组添加执行权限
chmod o+x 123.txt # 为文件其他人添加执行权限
chmod o=--- 123.txt #为文件其他人赋值执行权限
chmod o=rwx 123.txt #为文件其他人赋值执行权限
chmod 754 123.txt #为文件赋值执行权限
默认权限
[root@eric ~]# umask
0022
变更拥有者或者所属组
chown eric 123.txt 修改拥有者
chown eric:eric 123.txt # 修改拥有者:所属组
chgrp root 123.txt #变更所属组
本文暂时没有评论,来添加一个吧(●'◡'●)