Linux modify file permissions and user Group Management summary

Source: Internet
Author: User

How to modify group permissions under Linux

chmod g+r path/file Read permission current directory

Chmod-r g+r path/file Read permissions current directory and subdirectories

G-r Read-less permissions
G+w Write permission
G-w
G+x and Execute permissions
G-x

Always use the command, remember. 1.chgrp modifying the group to which the file belongs

#简单使用, change the text test.txt belongs group to GOURP1

Chgrp GOURP1 Test.txt

2.chown Modify File Owner

#将test. txt file belongs to user modified to User1

Chown user1 Test.txt

#同时修改test. txt's owning user and owning group

Chown User1:group1 Test.txt

3.chmod Modifying file properties

chmod 755 Test

chmod u+x Test

chmod u-x Test

chmod g+x Test

4.usrmod modifying the group to which the user belongs

In general, just add the current user to another group

Usrmod-a-G group1 user1

If you want to completely change the group that the user belongs to, use

Usrmod-g group1 user1

When you use Linux, you need to log in as a user to restrict the resources that a consumer can access, while groups are used to facilitate organization of administrative users.

Users and Groups

• Each user has a UserID
• Each user belongs to one primary group and belongs to one or more satellite groups
• Each group has a groupid
• Each process runs as a user and is limited by the resources accessible to that user
• A designated shell for each user who can login
The files in the system have a owning user and group, and the user and group information is saved in the following three files:
/ETC/PASSWD User Information

/etc/shadow User Password

/edc/group Group Information

The command ID is used to display the current user's information, the command passwd can modify the current user's password, the following command can display the login user information:

WHOAMI Show Current User

WHO displays current logged-in user information

W display details of the logged-in user

Command Useradd add a user:

Useradd User Name

-D Specify user home directory
-S Specify user login Shell
-U Specify user uid
-g Specifies the primary group to which the user belongs
-g Specifies the subordinate group to which the user belongs

Command Usermod to modify a user's information:

Usermod parameter User name
-L Modify User name
-U Modify UID
-G Modify User Master Group
-G Modify User Attachment Group
-L Lock User
-U Unlock User


Example 1:

# useradd-d/usr/sam-m Sam
This command creates a user Sam, where the-D and-m options are used to generate a home directory for the login Sam/usr/sam (/usr is the parent directory where the default user home directory resides).
Example 2:
# useradd-s/bin/sh-g group-g adm,root Gem
This command creates a new user gem, which is the login shell of/bin/sh, which belongs to the group user groups, and also to the ADM and root user groups, where group user groups are their primary groups.
There may be a new group: Groupadd Group and Groupadd ADM
Adding a user account is adding a record to a new user in the/etc/passwd file, while updating other system files, such as/etc/shadow,/etc/group.
Linux provides an integrated system management tool, userconf, that can be used to manage user accounts.
Note:
The user account itself is defined in/etc/passwd. The Linux system contains a/etc/passwd companion file, called/etc/shadow. The file is not like/etc/passwd and is readable only for the root user and contains encrypted password information

Command Userdel user to delete a user:

Userdel User Name
USERDEL-L user name deletes the user's home directory while deleting the user

Command Groupadd, Groupmod to create and modify a group:
Groupadd Group Name

Groupmod-n New group name old group name
GROUPMOD-G New group ID old group ID

For example:

# Userdel-r Sam
This command deletes the records of the user Sam in the system files (mainly/etc/passwd,/etc/shadow,/etc/group, etc.) and deletes the user's home directory.


Delete a group

Similarly, we sometimes need to delete a group, command Groupde to delete a group

Linux modify file permissions and user Group Management summary

Related Article

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.