User's basic permissions
1. Basic permissions UGO
1 Overview
Give a user or group how to access a file (picture file, video file, ordinary file), such as: Red Diamond privilege of QQ space
2. Authorization object
Owner: u
Group: g
Others: o
Everyone: a(u+g+o)
3. Permission type
Read: r=4
Write: w=2
Execution: x=1
4. View permissions
View permission records
[root@localhost ~]#ls -l /root/1.txt
-rw-r--r--. 1 root root 179 5月 25 14:27 /root/1.txt
- File Types
rw- the authority of the owner, the owner r-- the authority of the group, r-- the authority of others
5. Set permissions
⑴ 、 Grammar
Symbols used: u user g group o other r read w write x execute chmod object (u/g/o/a) assignment character (+/-/=) permission type (r/w/x) file/directory
⑵ , understand the basic permissions of ordinary files
[root@localhost ~]# cd /tmp
[root@localhost ~]# touch file1
[root@localhost tmp]# ll file1
-rw-r--r--. 1 root root 0 4月 13 20:49 file1
Permission Owner and Group File
⑶ , increase execution authority
[root@localhost tmp]# chmod u+x file1
⑷ , more modification permissions
[root@localhost tmp]# chmod a=rwx file1 // Everyone is equal to read and write execution
[root@localhost tmp]# chmod a=- file1 // Everyone has no permission
[root@localhost tmp]# chmod ug=rw,o=r file1 // Owner group is equal to read-write, others are read-only
[root@localhost tmp]# ll file1 // View file permissions in long mode
-rw-rw-r-- 1 alice it 17 10-25 16:45 file1 // displayed result
⑸ , Use digital setting permissions
4 read 2 write 1 execute
[root@localhost ~]# chmod 644 file1
[root@localhost ~]# ll file1
-rw-r--r-- 1 alice it 17 10-25 16:45 file1
6. Change the owner and group
⑴ , chown command
chown : Set who and owner a file belongs to
Syntax: chown user name. group name file
[root@localhost ~]# chown alice.hr file1 // Change owner and group
[root@localhost ~]# chown alice file1 // Change only the owner
[root@localhost ~]# chown .hr file1 // Change only to the group
[root@localhost ~]#chown -R user1.user2 /tmp/dir1/file1.txt // Modify the owner group of the file under the folder
⑵ , chgrp command
Syntax: chgrp group name file -R means recursive
[root@localhost ~]# chgrp it file1 // Change file group
[root@localhost ~]# chgrp -R it dir1 // Change file group
Two, basic permissions ACL
1. The difference
ACL file permissions management: Set different users, different basic permissions (r, w, x). The number of objects is different.
UGO set basic permissions: only one user, one group and other people
2. Grammar
setfacl -m u:alice:rw /home/test.txt
Command Set User or Group: User Name: Permission File Object
3. Usage
⑴ 、Prepare documents
[root@localhost ~]# touch /home/test.txt
[root@localhost ~]# ll /home/test.txt
-rw-r--r-- 1 root root 0 10-26 13:59 /home/test.txt
⑵ , set ACL
Set user alice and jack permissions: Prerequisite: create alice and jack users. The process is slightly
[root@localhost ~]# setfacl -m u:alice:rw /home/test.txt
[root@localhost ~]# setfacl -m u:jack:- /home/test.txt
[root@localhost ~]# setfacl -m o::rw /home/test.txt 设置文件其他人访问权限
4、查看/删除
⑴、查看ACL
[root@localhost ~]# getfacl /home/test.txt
⑵、删除ACL
[root@localhost ~]# setfacl -x g:hr /home/test.txt //删除组hr的acl权限
[root@localhost ~]# setfacl -b /home/test.txt //删除所有acl权限