To manage user accounts in a Linux system, there are several commands available that provide administrators with the necessary tools to create, modify, and delete user accounts. These commands offer a range of functionality, allowing for fine-grained control over user permissions and access privileges. In this answer, I will discuss some of the most commonly used commands for user account management in Linux.
1. useradd: The useradd command is used to create a new user account in Linux. When creating a new user, you can specify various parameters such as the username, user ID, home directory, default shell, and more. For example, to create a new user named "john" with a user ID of 1001 and a home directory of "/home/john", the following command can be used:
useradd -u 1001 -d /home/john john
2. passwd: The passwd command is used to set or change the password for a user account. By default, only the root user or a user with sudo privileges can change another user's password. To change the password for a user, simply execute the passwd command followed by the username. For example, to change the password for the user "john", you can use the following command:
passwd john
After executing this command, you will be prompted to enter and confirm the new password.
3. usermod: The usermod command is used to modify existing user accounts. It allows administrators to change various attributes of a user, such as the username, user ID, home directory, default shell, and more. For example, to change the default shell for the user "john" to "/bin/bash", you can use the following command:
usermod -s /bin/bash john
This command will modify the user account and set the default shell to "/bin/bash".
4. userdel: The userdel command is used to delete user accounts from the system. When deleting a user account, you can choose to remove the user's home directory and mail spool or retain them. By default, the userdel command only removes the user account and leaves the home directory intact. To delete a user account and remove the associated home directory, you can use the following command:
userdel -r john
This command will delete the user account "john" and remove the home directory.
5. chage: The chage command is used to modify the password expiry information for a user account. It allows administrators to set password expiration dates, disable password aging, and more. For example, to set the password for the user "john" to expire in 30 days, you can use the following command:
chage -M 30 john
This command will modify the password expiry information for the user "john" and set the maximum password age to 30 days.
These are just a few examples of the commands available for managing user accounts in Linux. Each command provides a specific set of functionalities that enable administrators to perform various tasks related to user account management. By utilizing these commands effectively, administrators can maintain a secure and organized user environment within a Linux system.
Other recent questions and answers regarding Examination review:
- How can the useradd command be used to create a new user account?
- What is the purpose of the `/etc/shadow` file?
- How are passwords stored and managed in Linux?
- What are the three important files for user account management in Linux system administration?

