Common commands for File system permissions operations of LINUX commands

Source: Internet
Author: User
Tags chmod readable

1. Umask: Set the permission mask syntax: umask [parameters]

Command description: Umask can be used alone, you can set the default permissions of the directory and file, the default permission mask is 022, so the default directory permissions are 777-022=755, read permission is 4, write permission is 2, the execution permission is 1, the first 7 is the owner's permission, the second 5 is the permission of the owning group, The third one is the rights of others, and the newly created file is 666-022=644,

Parameter description: The permission mask of the file or directory you want to view or set

command example: Use Umask alone to display as 0022, the first number represents octal number, negligible, but can be set by itself

Example: Umask 777

After setting up, you create a new file or directory, you will find that there is no permission to display

2. chmod: Change permission syntax for a file or directory: chmod [options] [parameters]

Command Description: You can change the file or directory to read, write, execute the permissions, respectively display as r,w,x, also can be used to replace the number, R for Read permission, the number is 4,w for write permission, the number is 2,x for the execution rights, the number is 1, all the permissions for a, that is, 7.

Common Options Description:

-r: Recursively change permissions for all files under directory and

Parameter description: The name of the file or directory you need to change

command example: For example, there is a 111 newly created file, because of the relationship of the permission mask, the file default is 666-0222=644, that is, the owner is readable writable, belong to the group and other people can read, we want to make 111 owner has all the permissions, the owning group has a readable writable, the other people do not have permissions, as follows:

chmod 760/111

With ls-l View/111 you can see the display as-RWXRW----, the first '-', for the type of file, display-is the file, D is the directory

3. Chown: Change the owning group syntax for the owner of a file or directory: chown [options] [parameters]

Command Description: Change the owner and group of the file or directory, but if you provide only the user name, the owning group will not change, if you want to change the owner and the owning group at the same time, you need to use a colon or dot separate

Common Options Description:

-R: Recursively change the owner and owning group of all files under directory and

Parameter description: The name of the file or directory you need to change

command example:

You are currently the root user, a new directory 123, then the owner of this directory and the owning group are root, we have an account for zhang3, to change the owner of the 123 directory and the owning group to Zhang3

Chown Zhang3:zhang3 123

Using Ls-l to view the directory, the owner and the owning group of 123 have been changed to Zhang3

4. Getfacl: View the Access control List syntax for a file or directory: Getfacl [options] [parameters]

Command Description: You can display the permission information of the file or directory you specified.

Common Command options:

-R: Recursively displays information about all files under the directory and

Parameter description: The specified directory or file you want to view

command example:

View home directory information, Getfacl/home

will be displayed: File:home file name

Owner:root owner

Group:root belongs to Group

USER:RWX Owner Permissions

Group:r-x Owning group permissions

Other:r-x other people's rights

5. Setfacl: Change the Access control list syntax for the settings file or directory: setfacl:[options [parameters]

Command description: Getfacl can view information about the access control list, and Setfacl can change the information in it, usually with the two commands

Common Options Description:

-M: Change the access control list for a file

-B: Delete All Access control List entries

-X: Remove entries based on the Access control list in the file

-r: Recursively change configuration directory and all files below

Parameter description: You specify the name of the file or directory you want to set

Command example: currently has a file named 111, you can first use Getfacl to view information, if you need to add information. OK

setfacl-m u zhang3:rwx 111 this way, when you use Getfacl view, you will find that there is a more user:zhang3:rwx under the user.

This is to add users, you can also use G, add groups, notice recursion,-R must be in the front of-m

    

Common commands for File system permissions operations of LINUX commands

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.