Search Tools Links Login

How to Add and Remove Users on Ubuntu


Ubuntu, one of the most popular Linux distributions, offers robust user management tools that allow administrators to efficiently control access to the system. Whether you're setting up a new user account or removing an old one, understanding the process is crucial for maintaining a secure and organized environment. In this guide, we'll walk you through the steps of adding and removing users on Ubuntu.

Adding Users

Create a New User

To add a new user, open a terminal window and use the adduser command. For example:

sudo adduser newusername

Follow the prompts to set a password and provide additional information if needed.

Grant Administrative Privileges

If you want to grant administrative privileges to the new user, add them to the sudo group:

sudo usermod -aG sudo newusername

This step allows the user to execute commands with elevated privileges.

Verify the New User

Log in as the new user to ensure the account was created successfully:

su - newusername

Removing Users

Remove User Account

To remove a user account, use the userdel command. This command only removes the user but leaves their home directory intact:

sudo userdel oldusername

Remove User Account and Home Directory

If you want to delete both the user account and its home directory, use the userdel command with the -r option:

sudo userdel -r oldusername

Additional User Management Tasks

Modify User Properties

Use the usermod command to modify user properties, such as the username, home directory, or shell:

sudo usermod -l newname oldname

Lock and Unlock User Accounts

Lock a user account to prevent login

sudo passwd -l username

Unlock a user account

sudo passwd -u username

View User Information

To display detailed information about a user, use the id command:

id username

Conclusion

Managing user accounts on Ubuntu is a fundamental skill for system administrators. Whether you are creating new users or cleaning up old accounts, the commands and steps outlined in this guide provide a solid foundation for effective user management. By following these practices, you can ensure a secure and organized Ubuntu system tailored to your specific needs.

About this post

Posted: 2024-01-15
By: dwirch
Viewed: 111 times

Categories

Tip

Tutorials

Linux Commandline

Linux

Ubuntu

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.