Linux权限管理是Linux中一个十分重要的概念,也是系统安全性的重要保障。这里主要介绍Linux的基本权限和默认权限,通过理论讲解与实验演示,可以详细了解到权限的相关操作及其重要性。
文件权限
[root@localhost ~]# ls -l /etc/passwd
-rw-r–r–. 1 root root 2133 Apr 16 11:33 /etc/passwd
[root@localhost ~]#
文件的权限:所有者,所属组,其他人
rwx,读、写、执行,没有权限就是“-”
第一个组rwx:文件所有者的权限
第二个组rwx:文件所属组的权限
第三个组rwx:文件其他人的权限
目录的权限:linux权限管理
r:具有读取目录结构列表的权限,可以查看目录下有哪些文件
w:该权限对于目录来说是很大的,
1、可以在该目录下新建新的文件和目录
2、可以删除已经存在的文件和目录
3、将已经存在的文件和目录重命名
4、移动目录内的文件和目录的位置
x:是否可以进入该目录
修改权限
chown命令:修改文件的拥有者,前提是要有该拥有者(-R 递归修改)
[root@localhost tmp]# tail -1 /etc/passwd
linux00:x:1001:1001::/home/linux00:/bin/bash
[root@localhost ~]# cd /tmp/
[root@localhost tmp]# touch file1
[root@localhost tmp]# ll file1
-rw-r–r–. 1 root root 0 Apr 26 08:56 file1
[root@localhost tmp]# chown linux00 file1
[root@localhost tmp]# ll file1
-rw-r–r–. 1 linux00 root 0 Apr 26 08:56 file1
[root@localhost tmp]#
chgrp命令:修改文件所属组,前提是要有该组(-R 递归修改)
[root@localhost tmp]# tail -1 /etc/group
xiuyuan:x:1002:
[root@localhost tmp]# ll file1
-rw-r–r–. 1 linux00 root 0 Apr 26 08:56 file1
[root@localhost tmp]# chgrp raoxiuyuan file1
[root@localhost tmp]# ll file1
-rw-r–r–. 1 linux00 xiuyuan 0 Apr 26 08:56 file1
[root@localhost tmp]#
chmod命令:修改拥有者和所属组的权限
● 加减法:u/g/o +/-/= r/w/x
● 数字法:r=4,w=2,x=1
[root@localhost tmp]# ll file1
-rw-r–r–. 1 linux00 root 0 Apr 26 08:56 file1
[root@localhost tmp]# chmod g+w file1
[root@localhost tmp]# ll file1
-rw-rw-