Users and user groups in Linux-Linux general technology-Linux technology and application information. For details, refer to the following section. The main task of user management is to create a legal user account, set and manage user passwords, modify user account attributes, and delete obsolete user accounts when necessary.
1) Add a new user
In Linux, only the root user can create a new user. The following command creates a user with the login name user1.
# Useradd user1
However, this user is not allowed to log on, because the initial password has not been set for it, and users without a password cannot log on to the system. By default, a user home directory with the same user name will be created in the/home directory.
In Linux, when a user is added, a new group is created. The Group has the same name as the user, and the user is a member of the group. To assign a new user to an existing group, run the following command:
# Useradd-g usergroup1 user1
In this way, the user is a member of usergroup1. If you want to make it belong to another group of usergroup2, use:
# Useradd-G usergroup2 user1
After completing this operation, you should also use the passwd command to set an initial password for it.
2) delete a user
To delete a user, you only need to use a simple command "userdel user name. However, it is best to delete the files that remain on the system. You can use "userdel-r username" to achieve this purpose.
3) Add a group
You can create user groups as needed:
Groupadd <Group Name>
4) delete a group
Similarly, we sometimes need to delete a group. Its command is groupdel.
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.