Linux create users and user groups

Source: Internet
Author: User

Linux create users, user groups, and delete

When you create a user, you specify a user group for the new user, and if you do not specify a workgroup to which the user belongs, automatically generates a workgroup with the same name as the user name. When creating user user1, specify the workgroup users they belong to, for example: Useradd–g users user1

First, create a user:

1. Using Command Useradd

Example: Useradd user1--creating a user User1
Useradd–e 12/30/2009 user2--Create user2, specify expiration date 2009-12-30
The default UID of the user is incremented from 500 to 500, which is the system reserved account, the UID can be specified,

Example: Useradd–u User3

2. Use the passwd command to set the password for the new user
Example: passwd user1
Note: Users who do not have a password set cannot use it.

3, command usermod Modify user account
Example: Change the login name of user user1 to U1,
Usermod–l U1 user1
Example: Adding user user1 to the Users group,
Usermod–g Users User1


Example: change user user1 directory to/users/us1
Usermod–d/users/us1 user1

4. Use the command Userdel to delete the user account
Example: Deleting a user User2
Userdel User2
Example: Deleting a user user3 and deleting his working directory
Userdel–r User3

5. View user Information
ID command to view the UID and GID of a user, for example: View user4 ID
ID user4
Finger command--can view the user's home directory, boot shell, user name, address, telephone and other information
Example: Finger user4

Second, the user group:

6. Command Groupadd Create user group
Groupadd–g 888 Users
Create a group of users whose GID is 888

7. Command GPASSWD add a user to a group
Only root and Group admins can change the members of a group:
Example: Adding User1 to the Users group
Gpasswd–a User1 users
Example: Exit the Users group with User1
Gpasswd–d User1 users

8. Command Groupmod Modify Group
Groupmod–n User users modify group name user to users

9. Groupdel Delete Group
Groupdel Users Delete Group users

Linux create users and user groups

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.