How to Add, Remove and Modify Users in Ubuntu Linux
Add, Remove and Modify Users in Ubuntu Linux (F.A.Q)
How do I create a user with specific privileges?
To create a new user with administrative privileges, you can use the adduser
command to add the user and then add them to the sudo group using usermod
. Here’s an example:
sudo adduser newusername
sudo usermod -aG sudo newusername
Replace “newusername” with the desired username. The second command adds the user to the sudo group, granting them administrative privileges.
Can I change a user's password without knowing the current one?
Yes, you can change a user’s password without knowing the current one. Use the passwd
command with the username:
sudo passwd username
Replace “username” with the actual username. You will be prompted to set a new password.
How can I prevent a user from logging in temporarily?
You can lock a user account to prevent login without removing it. Use the following command:
sudo passwd -l username
Replace “username” with the actual username. To unlock the account, use sudo passwd -u username
.
What's the safest way to remove a user and their files?
Use the userdel
command with the -r
option to remove the user and their home directory:
sudo userdel -r username
Replace “username” with the actual username. This command removes the user and their files. Be cautious, as this action is irreversible, and data will be permanently deleted.
0 Comments