Linux File Rights Management

Source: Internet
Author: User

First, set the user to which the file belongs and the group to which it belongs (CHOWN,CHGRP)


CHGRP is used to change the group owner of a file in the general format:
CHGRP [option] group file
(1) Change the group owner of the file test to ZFS:
CHGRP ZFS Test


(2) Change the group owner of all files under test and its subdirectories to ZFS:
Chgrp-r ZFS test



Chown is used to change the file owner and group owner in the general format:
chown [option] owner[:group] File
(1) Change the owner of all files under test and its subdirectories to ZFS:
Chown ZFS Test


(2) Change the owner of the test file to ZFS and the group owner to root:
Chown zfs:root Test



Second, give the file the appropriate permission bit (chmod)

The chmod command format is:
chmod [option] mode files ...

Mode indicates the format:
1, Digital way: [N][n][n] r=4 w=2 x=1
rwx:4+2+1;  r-x:4+1; Rw-:4+2
2. Text mode: [ugoa][+-=][rwx]
U – Owner of the file;
G-Persons belonging to the same group (group) as the owner of the file;
O-persons other than others;
+--Increase permissions
---Remove permissions
=--Set permissions


Give Rwxr-xr-x permission to the test file:
chmod 755 Test



Give rwxr-xr-x permissions to all files under test and its subdirectories:
Chmod-r 755 Test


Add permissions to a file by using the second method

Add RW permissions to the group owner of the file ABC
chmod G+RW ABC


Remove x permission for the user owner of the ABC file
chmod u-x ABC


Specify other user rights for file ABC to rw-
chmod o=rw-


Increase x permissions for all users of all files under file ABC and its subdirectories
Chmod-r a+x ABC



Sticky bit (sbit)

The role of the Sbit directory is: "In a directory with bit, if the user has W and x permissions in the directory, then when the user establishes a file or directory in that directory, only the file owner and Root have the right to delete."

4 for Suid
2 for Sgid
1 for Sticy Bit
#chmod 4777 Test
#chmod 2777 Test
#chmod 1777 Test




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.