Rights Management
R
W
X
Three types of users
U owner
G-Genus Group
o Other users
Change permissions for three categories of users
Chown Change file owner (only administrators can use this command)
#chown USERNAME File,....
Example #tail/etc/passwd (Find a user)
#ls/tmp-l (look at the files under the user)
#chown [user name]/tmp/abc (change owner)
Demo Step: #cd/tmp (CD to TMP)
#touch ABC (set up file ABC under TMP) the owner of this file is currently root
#ls-L/TMP/ABC (view ABC information)
#tail/etc/passwd (Find a user)
#chown USER2/TMP/ABC (Change the owner of ABC into User2)
#ls-L/TMP/ABC (look at ABC information again)
Chown can also change the directory owner
Demo Step #cd/tmp
#mkdir hi (Create a Hi directory under TMP)
#ls/tmp-l (view tmp information)
#chown User2/tmp/hi (Change the owner of Hi to User2)
#ls/tmp-l (View post-change information) or use #ls-ld/tmp/hi (view directory information, do not add D to see the files under Hi)
Chown-r modifying the owner of a directory and its internal files
Demo Step #cd/tmp/hi (CD to hi directory)
#touch a b c d ABC 123 (Create a file in the Hi directory)
#ls-L/tmp/hi (view information for the created file)
#chown-R User2/tmp/hi (change the owner of the Hi directory and the file under the directory)
#ls-L/tmp/hi (view post-change information)
Chown--reference=/path/to/somefile file,..... (Reference Reference | The owner of the file behind it is the same as the owner of the front file)
Demo Step #cd/tmp
#touch ABC
#chown--REFERENCE=/TMP/ABCD/TMP/ABC (Change the owner of ABC to the same as ABCD)
#ls-L/tmp
Chgrp GRPNAME file, ... Modify file group (same usage as chown) Only administrators have permission to execute this command
Demo Step #groupadd Yourgroup (set up a group, group name Yourgroup)
#cd/tmp
#touch 456 (Create a file under TMP 456)
#chgrp yourgourp/tmp/456 (change 456 genera to Yourgroup)
#ls-L/tmp
Chgrp-r
Demo Step #chgrp-r Yourgroup/tmp/hi (change the group of files in Hi directory and hi to Yourgroup)
#ls-L/tmp (view hi's genus Group)
#ls-L/tmp/hi (view the group of files under the Hi directory)
Chgrp--reference
Chown usename:grpname file, .... (Change both the owner and the group)
Step Demo #chown root:root/tmp/abc (change tmp/abc to master root, group root) = #chown Root.root/tmp/abc
#chown: Root/tmp/abc (change only the genus of ABC does not change the owner) or #chown root:/tmp/abc (change only the genus group)
Chown--reference
chmod: Modify permissions for a file
Modify permissions for three categories of users
chmod MODE file, ...
Chmod-r (Modify the file permissions in the directory)
Chmod--reference=/path/to/somefile file,... (with one file permission as standard, other file permissions modified to be the same)
Demo Step #chmod 750/tmp/abc (convert permissions to 8 binary)
Modify a class of user or some class user rights
U,g,o,a,
chmod user category =mode file, ...
Step Demo #chmod u=rwx/tmp/abc (change the permissions of the ABC owner to RWX)
#chmod u=r,o=r/tmp/abc (Change the permissions of the ABC owner to R, and the other user to R) #chmod UG=R/TMP/ABC (Multiple-class user Modify permissions can be combined write)
#chmod g=rx,o=/tmp/abc (change the permissions of the ABC owner to RX, other users do not have permissions)
Modify a user or some bit permission for a class
User Category U,g,o,a
chmod
Step demo #chmod u-x/tmp/abc (remove the execution authority of the ABC owner)
#chmod u+x,g-x/tmp/abc (adds the execution authority of the ABC owner, removing the execution rights of the group)
#chmod a+x/tmp/abc (Add the execution rights of the ABC three users, and in the case of all three types of users do not have permission to execute) A can be omitted
#chmod u-wx/tmp/abc (remove the WX authority of the ABC owner while operating multiple classes of permissions)
!!!!!!!!!!!!! Practice
1. Create a new user with no home directory OpenStack
2. Copy/etc/skel to/home/openstack
3. The main genus group that changes the/home/openstack and its internal files are OpenStack
4./home/openstack and its internal files, group and other users do not have any access rights
#useradd-M OpenStack (new user OpenStack without home directory)
#finger OpenStack (view user account information)
#ls/home (see House directory, no home directory is correct)
#id OpenStack (view user information)
#cp-R/etc/skel/home/openstack (copy/etc/skel to/home/openstack)
#ls-L/home (view House directory files)
#ls-L/home/openstack/-a (view user hidden file information)
#chown-R openstack.openstack/home/openstack/(the genus group that changes/home/openstack and its internal files are OpenStack)
#ls-ld/home/openstack (view directory information)
#ls-la/hoem/openstack (Product view directory hidden file information)
#chmod-R go=/home/openstack (/home/openstack and its internal files, group and other users do not have any access rights)
#ls-ld/home/openstack
#ls-la/home/openstack
#su-openstack
This article from the "11334516" blog, reproduced please contact the author!
Linux Permissions and Permissions management