August 1, 2023

How to Add and Delete Users on Ubuntu 20.04

mr rockstar

How to Add and Delete Users on Ubuntu 20.04

 


A Step-by-Step Guide to Adding and Deleting Users on Ubuntu 20.04


Introduction:

Ubuntu 20.04 is a popular Linux distribution known for its user-friendly interface and robust security features. Managing user accounts on Ubuntu is an essential administrative task that allows you to control access to your system effectively. In this guide, we will walk you through the process of adding and deleting users on Ubuntu 20.04, ensuring your system remains secure and organized.

 

Part 1: Adding Users on Ubuntu 20.04

 

Step 1: Accessing the Terminal :

To begin, open the Terminal by pressing Ctrl + Alt + T on your keyboard. The Terminal is where we’ll execute commands to add new users to the system.

 

Step 2: Adding a New User :

To add a new user, use the adduser command. Replace “newuser” with the desired username for the new account:

sudo adduser newuser
 
sudo adduser newuser 
Step 3: Setting User Password :

You’ll be prompted to set a password for the new user. Ensure it is strong and secure. The password will not be visible while typing.

Buy Cheap Linux VPS Plans – $7.99 / m

Step 4: Providing User Information (Optional) :

You can also provide additional information about the user, such as their full name, phone number, etc. This step is optional, and you can simply press Enter to skip it.

 

Step 5: Granting Administrative Privileges (Optional) :

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

sudo usermod -aG sudo newuser

Part 2: Deleting Users on Ubuntu 20.04

 

Step 1: Accessing the Terminal :

Open the Terminal as we did in Part 1.

 

Step 2: Deleting a User :

To delete a user, use the deluser command with the –remove-home option to delete the user’s home directory as well:

sudo deluser --remove-home username

sudo deluser

Replace “username” with the actual username of the user you want to delete.

 

 

Step 3: Additional Cleanup (Optional) :

You can also remove the user’s mailbox (if present) and any associated mail spool files with the following command:

sudo rm -rf /var/mail/username

Again, replace “username” with the appropriate username.

 

 

Conclusion:

Managing user accounts on Ubuntu 20.04 is a critical aspect of maintaining a secure and organized system. By following this step-by-step guide, you can confidently add and delete users with ease. Remember always to grant administrative privileges only to trusted users, and be cautious when deleting users, as it may result in data loss. Regularly reviewing and updating user accounts will help ensure the integrity of your Ubuntu 20.04 system.

Keywords: Ubuntu 20.04, Add User, Delete User, Terminal Commands, User Management, Linux Administration, Secure System, Tutorial.

 

 

Add and Delete Users on Ubuntu 20.04 (F.A.Q)

 
Can I add a new user without granting them administrative privileges?

Yes, you can add a new user without granting them administrative privileges. When adding a user, simply omit the step of adding them to the sudo group. This way, the new user will have regular user permissions and won’t be able to perform administrative tasks.

 

Is it safe to delete a user's home directory when removing their account?

Deleting a user’s home directory is generally safe as it will remove all their personal files and settings. However, before executing the deluser command with the --remove-home option, make sure you have backed up any essential data from the user’s home directory. If the user has valuable data, consider archiving it before deletion.

 

What happens to files owned by a deleted user on Ubuntu 20.04?

When you delete a user on Ubuntu 20.04, the ownership of their files and directories is reassigned to the root user. This ensures that the system can still access any shared or system-critical files that were owned by the deleted user.

 

Can I recover a deleted user account on Ubuntu 20.04?

Once you delete a user account using the deluser command, it is challenging to recover it completely. The user’s files and settings are permanently removed from the system. To re-enable the deleted user, you will need to create a new user with the same username, but any data from the old account will be lost.

Popular Blog Posts