The Linux system is a multi-user, multi-tasking time-sharing operating system. Any user who wants to use system resources must first apply for an account from the system administrator and then log into the system with this account.
A user’s account can help the system administrator track users who use the system and control their access to system resources; on the other hand, it can also help users organize files and provide security protection.
Each user account has a unique username and its own password.
When a user logs in with the correct username and password, they can access the system and their home directory.
To manage user accounts, the main tasks include the following:
Adding, deleting, and modifying user accounts.
Managing user passwords.
Managing user groups.
1. To add a new user account, use the useradd command with the following syntax:
useradd options username
Example 1
# useradd -d /home/sam -m sam
Example 2
# useradd -s /bin/sh -g group -G adm,root gem
<span>/bin/sh</span>
, belonging to the group user group, and also to the adm and root user groups, with group being the primary group.<span># groupadd group and groupadd adm</span>
2. Deleting an Account
<span>userdel</span>
command with the following format:userdel options username
# userdel -r sam
3. Modifying an Account
<span>usermod</span>
command with the following format:usermod options username
<span>-c, -d, -m, -g, -G, -s, -u, and -o</span>
, and the meanings of these options are the same as those in the <span>useradd</span>
command, allowing you to specify new resource values for the user.# usermod -s /bin/ksh -d /home/z -g developer sam

<span>passwd</span>
. The superuser can set passwords for themselves and other users, while ordinary users can only use it to modify their own passwords. The command format is:passwd options username
$ passwd
Old password:******
New password:*******
Re-enter new password:*******
# passwd sam New password:*******
Re-enter new password:*******
# passwd -d sam
# passwd -l sam
1. To add a new user group, use the groupadd command. Its format is as follows:
groupadd options usergroup
Example 1:
# groupadd group1
Example 2:
# groupadd -g 101 group2
2. To delete an existing user group, use the groupdel command with the following format:
groupdel usergroup
For example:
# groupdel group1
3. To modify the properties of a user group, use the groupmod command. Its syntax is as follows:
groupmod options usergroup
Example 1:
# groupmod -g 102 group2
Example 2:
# groupmod -g 10000 -n group3 group2
4. If a user belongs to multiple user groups, they can switch between groups to gain permissions from other groups.
$ newgrp root
This article contains some graphics and text sourced from the internet.
If there are copyright issues, please contact us promptly.