How To Use Useradd Command In Linux?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1. To add a user account in Linux, use the useradd command followed by the username. For example, to add a user named “John”, use the following command:
useradd john
2. To set the user’s password, use the passwd command followed by the username. For example:
passwd john
3. To assign a group to the user, use the groupadd command followed by the groupname. For example:
groupadd developers
4. To add the user to the group, use the usermod command followed by the username and the groupname. For example:
usermod -a -G developers john
5. To assign a home directory for the user, use the usermod command followed by the -d option. For example:
usermod -d /home/john john
6. To change the user’s login shell, use the usermod command followed by the -s option. For example:
usermod -s /bin/bash john
7. To lock the user’s account, use the usermod command followed by the -L option. For example:
usermod -L john
8. To unlock the user’s account, use the usermod command followed by the -U option. For example:
usermod -U john