Linux Add/Remove users and user groups

Source: Internet
Author: User

Display user Information
ID User
cat/etc/passwd

1, Build Users:
Useradd username//New user
passwd username//Set a password for the user

2. Build Working Group
Groupadd groupname//new workgroup

3, new users at the same time increase the Working group
USERADD-G groupname username//new user and added to workgroup

Useradd parameter:-G belongs to group-D home Directory-s settings used by shell

4. Increase the Working Group for existing users
Usermod-g groupname username (This will remove the user from the other group)

Usermod-a groupname username (this will simply add the user to the group and will not remove the user from the other group)

Or: Gpasswd-a user Group

If you want to make a group of people can sudo to an account in the group (for public account use) under
Can be set up under/ETC/SUDOERS.D a file content as follows, it can be the ETL group of all users can be cut to ETL users without password.
%etl all= (All) NOPASSWD:/bin/su ETL
%etl all= (All) nopasswd:/bin/su-etl

5. Temporary shutdown: The second field (password) in the/etc/shadow file that belongs to the user is preceded by a *. To restore the user, remove the *.

Or, use the following command to close the user account:
passwd username–l
Or
Usermod-l username

Re-release:
passwd Username–u
Or
Usermod-u username

6. Permanently delete user account
Userdel username
Groupdel GroupName
USERDEL-RF Peter (Force the deletion of the user and all files in the user's home directory)


7. Remove users from the group
Edit/etc/group Find the line where the user name is located delete
or with a command.
gpasswd-d username GroupName

Linux Add/Remove 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.