User groups, file permissions in Linux under the detailed

Source: Internet
Author: User

User groups
Each user in Linux must belong to a group and cannot be independent of the group. Each file in Linux has the concept of owner, group, other group

    • Owner

    • Your group

    • Other groups

    • Change the group where the user resides

Owner

Typically the creator of the file, who created the file, becomes the owner of the file naturally

You can see the owner of the file with the Ls‐ahl command

You can also use the Chown user name file name to modify the file owner

The group where the files are

When a user creates a file, the group where the file is located is the group that the user is in

All groups of files can be seen with the Ls‐ahl command

You can also use the CHGRP group name file name to modify the group in which the file resides

Other groups

Other users of the system are other groups of files, except for the owner of the file and the user in the same group

File permissions
Ls

The contents shown in-L are as follows:

    • 10 characters to determine what different users can do with a file
    • The first character represents a file (-), a table of contents (d), and a link (l)

    • The remaining characters are set per 3 (RWX), read (R), write (W), execute (x)

    • First set of rwx: The permissions of the file owner are read, write, and execute

    • Second set of rw-: Permissions for users of the same group as the file owner are read, write, but cannot be executed

    • Third group r--: permissions for other users who are not in the same group as the file owner are read and cannot be written and executed

Also available as a number: R=4,w=2,x=1 so rwx=4+2+1=7

    • 1 indicates the number of files connected

    • Root indicates that the user

    • Root indicates the group to which the user resides

    • 1213 indicates file size (bytes)

    • Feb 2 09:39 indicates last modified date

    • ABC indicates file name

Commands to change permissions

chmod changing the permissions of a file or directory

chmod 755 ABC: Give DEMO01.SH permission Rwxr-xr-x

chmod u=rwx,g=rx,o=rx demo01.sh: Same as u= user rights, g= group permissions, o= different groups of other user rights

chmod u-x,g+w demo01.sh: To ABC remove user-executed permissions, increase group Write permissions

chmod a+r demo01.sh: Add Read permissions to all users

Change owner (chown) and user Group (CHGRP) commands

Chown xiaoming ABC: Change the owner of ABC to Xiaoming

CHGRP Root ABC: Change the group that the ABC belongs to IS root

Chown root./ABC: Change ABC the owner of this directory is root

Chown‐r root./ABC: Change the ABC directory and the owner of all files and directories below it is root

Change the user group

When you add a user, you can specify which group to add the user to, as well as root administrative permissions to change the group in which a user resides

    • USERMOD‐G Group name User name

You can use

    • Usermod‐d Directory name User name, change the initial directory of the user login

User groups, file permissions in Linux under the detailed

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.