How to create and manage user accounts on Linux
Overview:
In the Linux operating system, the creation and management of user accounts is one of the important tasks of the system administrator. By creating and managing user accounts, you can control user access and permissions to system resources. This article will introduce how to create and manage user accounts on Linux, including operations such as creating users, deleting users, disabling users, and changing user passwords. It also comes with code examples.
1. Create a user account
useradd <用户名>
For example, create a user named "testuser":
useradd testuser
passwd <用户名>
For example, set the password of user "testuser":
passwd testuser
useradd -p <密码> <用户名>
For example, create a user named "testuser2" with a password of "123456":
useradd -p 123456 testuser2
2. Manage user accounts
userdel <用户名>
For example, to delete user "testuser":
userdel testuser
usermod -L <用户名>
For example, to disable user "testuser2":
usermod -L testuser2
usermod -U <用户名>
For example, unban user "testuser2":
usermod -U testuser2
passwd <用户名>
For example, change the password of user "testuser":
passwd testuser
3. Other user management related commands
su <用户名>
For example, switch to the identity of user "testuser":
su testuser
whoami
w
su -
finger <用户名>
For example, view the user "testuser" Detailed information:
finger testuser
Conclusion:
Through the introduction of this article, we can learn how to create and manage user accounts on Linux. System administrators can easily perform these operations with the appropriate commands and options. When you need to provide access and permissions to a new user, you can use the useradd command to create a user and set a password. When the user no longer needs to access the system or the account is abused, it can be disabled or deleted through the userdel or usermod command. At the same time, the user password can also be modified through the passwd command. These operations can be completed in the terminal or shell, and user accounts can also be managed in batches through scripts and batch processing. I hope this article is helpful to your user management on Linux.
The above is the detailed content of How to create and manage user accounts on Linux. For more information, please follow other related articles on the PHP Chinese website!