Add a System Administrator group to CentOS and perform related operations

Source: Internet
Author: User

Add a System Administrator group to CentOS and perform related operations

1. User Creation:

Adduser phpq // create a phpq user
Passwd phpq // set a password for the phpq user

2. Create a working group
Groupadd test // create a test workgroup

3. Create a user and add a Working Group
Useradd-g test phpq // create a phpq user and add it to the test workgroup

Note: SHELL used by-g's group-d home directory-s

4. Add a working group for existing users

Usermod-G groupname username

Or: gpasswd-a user group

5. temporarily close: Add * before the second field (password) of the user's row in the/etc/shadow file. To restore the user, remove.

You can also use the following command to disable the user account:

Passwd peter-l

Release again:

Passwd peter-u

6. Permanently delete user accounts

Userdel peter

Groupdel peter

Usermod-G peter (Force delete all files and subdirectories in the user's home directory and Home Directory)

7. delete a user from the group

Edit/etc/group and find the line GROUP1. Delete A or use the command gpasswd-d a group.

8. Display User Information

Id user
Cat/etc/passwd

Su root

Supplement: Methods for viewing users and user groups

User List file:/etc/passwd
User group list file:/etc/group

View the users in the system: cut-d:-f 1/etc/passwd
View users who can log on to the system: cat/etc/passwd | grep-v/sbin/nologin | cut-d:-f 1
View user operations: w command (root permission required)
View A User: w User Name
View logon User: who
View User Logon history: last

Passwd option User Name

Available options:

-L the password is disabled.

-U password unlock.

-D indicates that the account has no password.

-F forces the user to change the password upon next login.

If the default user name is used, modify the password of the current user.

For example, if the current user is sam, the following command modifies the user's own password:

$ Passwd

Old password :******

New password :*******

Re-enter new password :*******

If you are a super user, you can specify the password of any user in the following form:

# Passwd sam

New password :*******

Re-enter new password :*******

When a common user modifies his or her own password, the passwd command First asks for the original password and then asks the user to enter the new password twice. If the two passwords are the same, the original password is not required when the superuser specifies a password for the user.

For the sake of system security, you should select a complicated password. For example, you 'd better use an 8-bit long password, which contains uppercase letters, lowercase letters, and numbers, it should be different from the name and birthday.

When you specify a blank password, run the following commands:

# Passwd-d sam

This command deletes the password of the user sam, so that the system will not ask for the password during the next logon.

The passwd command can also use the-l (lock) option to lock a user so that the user cannot log on. For example:

# Passwd-l sam

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.