Common Linux commands (2)-permission management commands

Source: Internet
Author: User

1. Command name: chmod

Execution permission: All Users

Function Description: Change the file or directory permissions.

Syntax: chmod [{Ugo} {+-=}{ rwx}] [file or directory]

[Mode = 421] [file or directory]

Add or remove permission files or directories to or from the CHMOD User Type

 
Add the execution permission [root @ localhost ABC] # chmod U + x a to the owner of file a minus the read permission [root @ localhost ABC] # chmod o-r A sets the read and write permissions for the group to which file a belongs. [root @ localhost ABC] # chmod g-RW

Authorize by number

Rwx read/write execution

R ---> 4, W ---> 2, X ---> 1

For example: rwxr-XR -- this permission corresponds to 754

RW-r-X -- X. The permission corresponds to 651.

 
Set the read/write execution permission rwx for the owner of File A, and the read/write permission of the group RW-. If the owner has the read permission r --, the corresponding number is: 764 [root @ localhost ABC] # chmod 764

A user has the write (w) permission on a directory, which means that the user can create and delete files in the directory, even if the user has no write (w) permission on the files in the directory

 

2. Command name: chown

Execution permission: All Users

Function Description: Change the owner of a file or directory.

Syntax: chown user [file or directory]

 
Change the owner of file a to luxh [root @ localhost ABC] # chown luxh

3. Command name: chgrp

Execution permission: All Users

Function Description: Change the group to which a file or directory belongs.

Syntax: chgrp [user group] [file or directory]

 
Change the group of file a to ADM [root @ localhost ABC] # chgrp ADM a [root @ localhost ABC] # ls-l a-rwxrw-r --. 1 luxh ADM 0 Nov 15 05:22

 

4. Command name: umask

Execution permission: All Users

Function Description: displays and sets the default permissions for files.

Syntax: umask [-S]

-S displays the default permissions of new files or directories in the form of rwx

[Root @ localhost ABC] # umask0022 [root @ localhost ABC] # umask-su = rwx, G = RX, O = RX [root @ localhost ABC] #

0022 meaning:

0 -- Special Permission bit;

022 -- user permission bit, permission mask value, actual permission value: 777-022 = 755

Use: umask mask value can change this value, but it is not recommended to change this value

Linux permission rules: the executable (x) permission cannot be granted to files created by default.

 

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.