Linux Learning Notes: Users and Groups
First, what is the users and user groups
User: the person using the operating system
User groups: a group of users with the same system privileges
Second, associated with the user and group profiles
Information / etc / group to store the current system, all user groups
Format: Group Name: Password placeholder group: Group ID: Username list group
Note: (1) user password, natural user group has its own password.
(2) If the group has only one user and user group with the same name and then a list of users in a group can be omitted. Thus, in
Profiles can see a lot of users in the group list is empty, it may not really empty.
(3) root user group number must be 0
(4) group number from 1 to 499 belonging to the group numbering system reserved. It is generally reserved for the software installed on the operating system or
Services, such as you install MYSQL, it will have a group number.
User group number (5) user manually created for the 500 ~.
(6) group password placeholder with X all represented.
/ Etc / gshadow current password information storage system user group
Format: Group name: Group Password: Group manager: group user list
Note: (1) group password is empty or is * or is! , It can be considered the group password is empty.
(2) group general manager is empty, which means that all users of the group can manage the user groups
Information / etc / passwd to store the current system, all user groups
Format: Username: Password placeholders: User ID: User Group ID: User comment information: the user's home directory: shell type
Note: (1) user comment information that is created when a user can add some comments to this user information.
(2) the user's home directory, that user root out other user's time will create in your home directory
Create a user in the same directory as their name used to store the user's personal files directory.
(3) the superuser root user ID is necessarily 0
All the user's password information / etc / shadow to store the current system
Format: Username: Password :::::
Note: The password is encrypted in general, you can not see the real password.
Third, the basic commands of users and user groups
groupadd group name // Add User Group
groupadd -g group number Group name // add user groups and assign group number
groupmod -n new group name of the original group name // Change a group name
groupmod -g group number Group name // change the user group number
groupdel group name // delete a user group
useradd username // add a user, where the user group and user names with the same name
useradd -g group username // add a user name, specify it in the group
useradd -d directory username // add users to develop their user's home directory, where the group not specified, the default user name for the user group name
usermod -c Note User Name // add comments to specify a username
usermod -l new user name old username // change the user name
usermod -d directory path to the user to change the user name // Personal Folders
usermod -g new user username // Change the specified user group belongs
userdel username // delete a user, but does not delete the user's personal folder file
userdel -r username // delete users and delete users' personal folder file
Fourth, advanced users and groups command
passwd -l username // lock the user
passwd -u username // Unlock
passwd -d username // clear the password, the user can log in without a password
gpasswd -a username affiliated group // add to the user group subsidiary
gpasswd -d username affiliated group // delete the user from the affiliated group
// newgrp group name of the user group to switch to the affiliated group
useradd -g group1 -G group2, group3 ... // specify the main user groups and affiliated groups
gpasswd username // change the group password, enter the appropriate instructions will be
id username // Display the user information, including user ID, user ID, group number and the name of the main sub group list
su username // switch to other users under
su behind nothing // then switch to the root user represents
whoami // display the currently logged on user name
groups Username // display all the user's groups, including the main group and subsidiary groups