Linux permissions, owner, group, other group (other people), Chmod,chown

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



-Other groups

-Change the group where the user is located


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


The contents shown in-L are as follows:

-rwxrw-r‐-1 root root 1213 Feb 2 09:39 ABC

-10 characters to determine what different users can do with a file

-the first character represents a file (-), directory (d), link (l)

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

-First set of rwx: The file owner's permissions are read, write, and execute

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

-Third group r--: the permissions of 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 ABC permission rwxr-xr-x

chmod U=RWX,G=RX,O=RX ABC: ibid. u= User Rights, g= group permissions, o= different groups of other user rights

chmod u-x,g+w ABC: for ABC to remove user-executed permissions, increase group Write permissions

chmod a+r ABC: 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

Note: Chown can modify the owner and the group at once. Usage examples

Example 1: Changing Owners and groups


Chown Mail:mail Log2012.log




  Example 2: Change the file owners and groups "and instance 1 is the same effect, another way of writing"


Chown Root:log2012.log




  Example 3: Changing file groups


Chown:mail Log2012.log




  Example 4: Changing the owner and group of all files in the specified directory and its subdirectories


Chown-r-V Root:mail test6


[[email protected] test]# lldrwxr-xr-x 2 root users 4096 11-30 08:39 TEST6[[EMAIL&NB Sp;protected] test]# chown-r-v root:mail test6 "Test6/log2014.log" the owner has changed to Root:mail "Test6/linklog.log" owner has changed to root: The owner of Mail "Test6/log2015.log" has changed to root:mail the owner of "Test6/log2013.log" has changed to Root:mail "Test6/log2012.log" owner has been reserved as root: The owner of Mail "Test6/log2017.log" has changed to root:mail the owner of "Test6/log2016.log" has changed to root:mail the owner of "Test6" has changed to Root:mail[[email  protected] test]# lldrwxr-xr-x 2 root mail 4096 11-30 08:39 test6[[email protected] test]# CD TEST6[[EMAIL&NB Sp;protected] test6]# ll Total 604---xr--r--1 root mail 302108 11-30 08:39 linklog.log---xr--r--1 root mail 302108 11-30 08: log2012.log-rw-r--r--1 root Mail 11-30 08:39 log2013.log-rw-r--r--1 root mail 0 11-30 08:39 log2014.log-r w-r--r--1 root mail 0 11-30 08:39 log2015.log-rw-r--r--1 root mail 0 11-30 08:39 log2016.log-rw-r--r--1 root Mail 0 11-30 08:39 log2017.log 

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

"Comprehensive Case"

"Question 1.1" establishes two user groups Group1 and group2, and three users Dennis, Daniel, Abigale, and assigns the first 2 users under the Group1 user group, and the latter is assigned under the GROUP2 user group

"Question 1.2" to Dennis User login, create a file

Question 1.3 Logs in with a Daniel user to see if you can access the/home/dennis directory and read or write the file it created

"Question 1.4" to Dennis User login, modify the directory/home/dennis and file read and Write permissions (correct: Modify directory permissions, should use 770, not 760, otherwise insufficient permissions)

"Question 1.5" repeat "question 1.3"

"Question 1.6" change Abigale user group from group2 to Group1

You can then use CAT/ETC/PASSWD to view and determine


-Groupadd group name, adding groups to Linux

-Vi/etc/group, see all the group information in Linux, can be edited

-Cat/etc/group, view all the group information in Linux, can not be edited

-USERADD‐G group name User name, create a user and specify which group to assign the user to

-VI/ETC/PASSWD, see all user information in Linux, can be edited

-CAT/ETC/PASSWD, view all the user information in Linux, can only see can not edit

Linux permissions, owner, group, other group (other people), Chmod,chown

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: 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.