Linux Study Notes: Users and user groups

Source: Internet
Author: User

Linux Study Notes: Users and user groups

Linux Study Notes: Users and user groups

1. What are users and user groups?

User: user of the Operating System

User Group: A group of users with the same system Permissions

2. configuration files related to users and user groups

/Etc/group stores information about all user groups in the current system

Format: group name: group password placeholder: group number: User Name List in the group

Note: (1) the user has a logon password and the user group has its own password.
(2) If there is only one user in the group and the user group has the same name, the user list in the group can be omitted without writing. Therefore
The user list in multiple groups is empty in the configuration file.
(3) The Group Number of the root user group must be 0.
(4) group number 1 ~ 499 belongs to the group number reserved by the system. Generally, it is reserved for software installed in this operating system or
For example, if you have installed MYSQL, it has a group number.
(5) The number of user groups manually created by the user is 500 ~.
(6) All group password Placeholders are represented by X.

/Etc/gshadow stores the password information of the user group in the current system

Format: group name: group password: Group Administrator: group user list

Note: (1) the group password is null, *, or !, The group password can be considered empty.

(2) Group administrators are generally empty, which means that all users in the group can manage this user group.

/Etc/passwd stores information about all user groups in the current system

Format: Username: Password placeholder: user No.: User Group No.: User comment: User main directory: shell Type

Note: (1) when creating a user, you can add some remarks to the user.

(2) The user's main directory, that is, other users with root users will be in the home directory when they are created.

Create a directory with the same user name to store the user's personal file storage directory.

(3) The Super User root User number must be 0

/Etc/shadow stores password information of all users in the current system

Format: User name: Password :::::

Note: passwords are generally encrypted and cannot be seen as real passwords.

3. Basic commands for users and user groups

Groupadd group name // Add User Group
Groupadd-g group number group name // Add a user group and specify the group number
Groupmod-n new group name original group name // Change User Group Name
Groupmod-g group no. group name // Change User Group No.
Groupdel group name // delete user group

Useradd user name // Add User, the same name as the user group
Useradd-g group name username // Add User to specify the group to which the user belongs
Useradd-d directory username // Add a user to specify the Home Directory of the user. If the user group is not specified, the default username is the user group name.
Usermod-c annotation username // Add annotation for the specified Username
Usermod-l new username old username // change Username
Usermod-d directory username // change the path of the user's personal folder
Usermod-g New User Group username // change the group of the specified user
Userdel username // Delete the user, but do not delete the files in the user's personal folder
Userdel-r user name // delete a user and delete files in the user's personal folder

4. Advanced commands for users and user groups

Passwd-l user name // lock the user
Passwd-u user name // unlock
Passwd-d user name // clear the password so that the user can log on without a password
Gpasswd-a user name affiliated group // Add affiliated group to the user
Gpasswd-d username affiliated group // delete a user from the affiliated group
Newgrp group name // switch the user group to the affiliated group
Useradd-g group1-G group2, group3. // specify both the primary and secondary user groups.
Gpasswd username // change the password. Press enter and a prompt is displayed.

Id username // display specified user information, including user id, user id, main group id and name, and affiliated group list
Su user name // switch to another user
Su does not connect anything. // It indicates that it is switched to the root user.
Whoami // display the current logon User Name
Groups user name // display all groups of the user, including the main group and affiliated group

This article permanently updates the link address:

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.