Linux in Chown, chmod, chgrp

Source: Internet
Author: User

1, CHGRP (change the file belongs to the user group)

CHGRP (transform file to user group) change Group

CHGRP user Group filename # # #便是这个格了. If the entire contents are changed, the plus-r parameter is used for recursion.

Example: Chgrp-r user smb.conf

2. Chown (change file owner)

Format: chown-r-H User name file/Catalog

The-r option represents the same operation for files in all subdirectories, and the-h option means that the target file that the link points to is not affected when the owner of the symbolic link file is changed.

Note: Once ownership of a file is given to another user, it is no longer possible to reclaim its ownership and ultimately only to the system administrator.

Chown User name: User group: File/Catalog

If the entire contents are changed, the plus-r parameter is used for recursion.

Example: Chown-r root/etc/config.cfg

Chown-r Root:root/home

3, chmod (change file attributes)

+ hint add permission,-hint to dismiss permission, = imply only set permission.

R implies readable, W implies writable, X implies can be implemented, x implies that only if the file is a subdirectory, presumably the file has been set up for implementation.

--version: Performance version

By letter notation

Example 1: Set the file file1.txt to be read by all people:

chmod ugo+r File1.txt

U (user) represents the current user, the first three-bit 2-4-bit

G (group) represents the group in which the second three-bit 5-7-bit

O (Other) on behalf of the other, in the third three-bit 8-10-bit

Example 2: Set the file file1.txt to be read by all people:

chmod a+r File1.txt

In numerical notation

Permissions for User, Group, and other.

R W X

-   - - -   - - -   - - -

111 111 111

The decimal that each digit represents by using the binary algorithm

R=4,w=2,x=1

To rwx the attribute then 4+2+1=7;

To rw-the attribute then 4+2=6;

To r-x the property, 4+1=5.

  

Linux in Chown, chmod, chgrp

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.