Linux File Permissions Analysis

Source: Internet
Author: User
Tags readable file permissions

  First, user group concept

in a Linux system, each user must belong to a group and cannot be independent of the group. Each file has the three concepts of owner, group, and other group.

(1) Owner: Typically the creator of the file, who created the file, becomes the owner of the file, can view the owner of the file with the Ls-ahl file name , or you can modify the file owner by using the chown user name file name .

(2) Group: When a user creates a file, the group that the a user is in is the group where the file is located, you can use the Ls-ahl file name to view the group of files, you can modify the group of files by using the CHGRP group name file name.

(3) Other groups: except for the owner of the file and the user in the group, other users of the other group are other groups of files.

  Ii. interpretation of the file Permissions command

Go to the directory where the Mm.txt file is located, enter the command Ls-ahl mm.txt can see the following results

    -rwxr--r--1 Kaiye Kaiye April mm.txt

The row results output record the permissions of the file and other information, below one by one interpretation

First character:-Represents the file, D represents the directory, and L represents the link

    rwxr--r--: Each of the three groups, R for Read permission, W for write permission, X for the executable

(1)rwx: A readable writable executable that represents the permissions of the file owner

(2)r--: the permissions on behalf of users of the same group as the file owner are readable but not writable, not executable

(3)r--: The rights of other users representing different groups of file owners are readable, but not writable, and cannot be executed

Read, write, enforceable permissions can also be represented by numbers as: r=4,w=2,x=1

    1: indicates the current number of connections to the file

    First Kaiye: Indicates the owner of the file

    Second Kaiye: Represents the group where the file owner resides

    BYTE : indicates bytes

    APR: Last Modified time

    mm.txt: indicates file name

  Third , file permissions modification

    chmod: Changing the permissions of a file or directory

chmod 755 mm.txt gives Mm.txt permission Rwxr-xr-x

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

chmod u-x,g+w mm.txt: To mm.txt Remove user-executed permissions, increase group Write permissions

chmod a+r mm.txt: Add Read permissions to all users

    Chown: Changing the file owner

CHGRP: Changing the group in which files are located

    Chown Yukai mm.txt: Change the owner of the file mm.txt for the user Yukai

CHGRP root mm.txt: Change file mm.txt in the same group as 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

    Usermod: Change the user's group or the initial directory at the time of login, when adding a user, you can specify the group that the user is in, the same subsequent actions can change the user's group or the initial directory at logon.

    USERMOD-G group user name--usermod-g root Kaiye change the group of users Kaiye to root

Usermod-d Directory Username---usermod-d/home Kaiye The initial directory where the user Kaiye login

Linux File Permissions Analysis

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.