How to easily add and delete users on Ubuntu

If you are sharing your Ubuntu PC with other users, you should create an account for each user. That will allow each user to personalize their account the way they want.

Each person can have their own wallpaper, settings, and browser favorites. If any user stops using your PC, you should consider deleting that account as well. You can easily add or remove users on Ubuntu through the terminal by following the steps below.

How to add a new user account on Ubuntu

On Ubuntu PCs (and indeed on most Linux distributions), user accounts can have different levels of access and permissions. Each user gets a specific ID number called a user ID (or UID) and their own home directory where they can store their personal files.

Sometimes, you may need to add new users. This can be easily done from Terminal using the adduser command. You will need root access to do this - you can elevate the command with sudo. To add a new user account on Ubuntu, follow these steps.

1. Open a new terminal window.

2. Type sudo adduser user , replace user with the desired user name, and press Enter .

3. You will be prompted to create and verify a password for the new user - follow the on-screen instructions to do this.

4. Follow the prompts to fill in the new user's information. You can bypass this by pressing Enter for each prompt.

Picture 1 of How to easily add and delete users on Ubuntu

5. Once completed, the new user will be ready to use their account.

How to grant root access to users on Ubuntu

If you recently created a new user account and want to give it root-level access on your Ubuntu PC, you can do so using the usermod command. Giving a user root access on Ubuntu means adding that user to the sudo group , meaning they can elevate their commands to run as root.

Allowing users to run commands as sudo poses certain risks because they will be able to access any file or folder on your PC and make any changes they want to the system. your system. Only give users superuser permissions if you trust them - otherwise, let them have regular user access.

To grant root access to a user on Ubuntu, follow these steps.

  1. Open a new terminal window.
  2. In Terminal, type sudo usermod -aG sudo user , replace user with the correct username, and press Enter .
  3. To verify the user has been added to the sudo group, type groups user and press Enter , replacing user with the username. This will list that the user is currently a member of the sudo group .

Picture 2 of How to easily add and delete users on Ubuntu

How to delete user accounts on Ubuntu

If you want to delete your Ubuntu user account, you can use the deluser command (as long as you have root access with sudo). You can use this command to remove users and leave their home directory intact. Additionally, if you want to delete their files, you can also use it to delete their home directory.

To remove Ubuntu users, follow these steps.

1. Open a new terminal window.

2. Type sudo deluser user to delete the user account without deleting their home directory. Replace user with the correct username before you press Enter , and provide your password if prompted to do so.

Picture 3 of How to easily add and delete users on Ubuntu

3. If you also want to delete the user's home directory, type sudo deluser --remove-home user (replace user with the correct username) and press Enter .

Picture 4 of How to easily add and delete users on Ubuntu

4. Next, enter the user id (replace user with the correct username). If the command is successful and returns a value, the username still exists and you may need to repeat the process. If it fails with such a no user error message then the user account has been successfully deleted.

Picture 5 of How to easily add and delete users on Ubuntu

Manage access to your Ubuntu PC!

Using the steps above, you will be able to quickly manage access to your Ubuntu PC by adding and removing users as needed. Adding a new user account is simple, but if you decide to delete an account, make sure to back up any files from their user folder first - you may lose them in the process.

Be sure to control who has root-level administrative access, depending on who is planning to use your PC.

Update 01 March 2024
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile