Home Terminal Tuts How to add, remove, and rename Users by command-line in Ubuntu, Linux Mint

How to add, remove, and rename Users by command-line in Ubuntu, Linux Mint

by Kiran Kumar
Published: Updated:
add_remove_users by command-line ubuntu

In this session of our Terminal Tuts series, let’s learn how to add, remove, and modify user accounts from the terminal using commands in Ubuntu, Linux Mint, and derivatives.

View list all the users of your PC

Before heading to add, remove, and modifying the users, let’s first know how to view the list of user accounts in your PC.

System user accounts is stored in the file etc/passwd. We will use cut command in combination with a delimiter and a fetch field function. Launch ‘Terminal’ and run the following command.

cut -d: -f1 /etc/passwd

In the above command, we are using cut to remove a part from each line of the file etc/passwd and using a delimiter d for field. Also the f1 selects the first part from the mentioned file in the path provided. So the actual file content can be seen just by using the following command. You will lot of information. The above command filters only the name which we want.

cat /etc/passwd
cat /etc/passwd Output

cat /etc/passwd Output

Add New User Accounts

To add new user accounts in Ubuntu, you can use adduser or useradd command. Both gives same result. Replace ‘username’ with the name you want in the below command.

sudo adduser username

This will add the new user with all default settings applied. If you want the new user to be a part of a group you can add the group at last. Replace ‘user name’ and ‘usergroup’ with name and group you want respectively. For example:

sudo adduser username usergroup

Remove User Account and Data

To delete a user account in Ubuntu, use the deluser command. Replace ‘username’ with name you user account name you want to delete on your PC.

sudo deluser username

You may want to delete that user’s home directory as well. Use ‘Remove’ (rm) command:

sudo rm -r /home/username

If you want to remove all the files, use this command too:

sudo deluser --remove-all-files username

To Rename a User Account

If you want to modify an existing user account, use the following command format. Replace new_username and old_username accordingly with what you want.

usermod -l new_username old_username

Change Password of an User Account

You can change he password for a user account using passwd command:

sudo passwd username

Hope these commands are useful to you. Good luck!

You may also like

Leave a Comment



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us


©2016-2023 FOSS LINUX



“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.