This tutorial will show you how to add new user in Ubuntu 20.04 using command adduser and through GUI, also will show you how to remove/delete a user account.

Introduction

useradd is a low level utility for adding new users . On Debian or Ubuntu we should usually use adduser instead.

adduser is a Perl script which can be used to add users into Ubuntu according command line options and configuration information in /etc/adduser.conf, it’s more friendly compare to low level command useradd .

j@ubuntu2004:~$ file /usr/sbin/adduser
/usr/sbin/adduser: Perl script text executable

Add new user in Ubuntu from command line

Below steps will show you to add a new user in ubuntu using both adduser and useradd

add a new user using command adduser

sudo adduser username

Below is the output of an example,where we need to set password for this new user , and we can set some information like Name ,phone number for this account

j@ubuntu2004:~$ sudo adduser user01
[sudo] password for j: 
Adding user `user01' ...
Adding new group `user01' (1001) ...
Adding new user `user01' (1001) with group `user01' ...
Creating home directory `/home/user01' ...
Copying files from `/etc/skel' ...
New password: 
Retype new password: 
passwd: password updated successfully
Changing the user information for user01
Enter the new value, or press ENTER for the default
	Full Name [Jack]: 
	Room Number []: 
	Work Phone []: 
	Home Phone []: 
	Other []: 
Is the information correct? [Y/n] y
j@ubuntu2004:~$ 

Per the output we can see adduser will copy files under directory /etc/skel into this new create user’s home directory. These are some shell configuration files.

j@ubuntu2004:~$ ls -a /etc/skel
.  ..  .bash_logout  .bashrc  .profile

(Optional)Add user into a group

If we need to give this new create user sudo access ,we can use below command to add this user into sudo group

sudo usermod -aG sudo username

We can verify using command groups

j@ubuntu2004:~$ groups user01
user01 : user01 sudo

Force user to change password in first login

To do this we can use command chage which changes the number of days between password changes and the date of the last password change.

sudo chage -d 0 username

To verify the change we can use below command

j@ubuntu2004:~$ sudo chage -l user01
Last password change					: password must be changed
Password expires					: password must be changed
Password inactive					: password must be changed
Account expires						: never
Minimum number of days between password change		: 0
Maximum number of days between password change		: 99999
Number of days of warning before password expires	: 7
j@ubuntu2004:~$

Delete a user in Ubuntu from command line

Similarly , in ubuntu there are commands userdel and deluser , userdel is a low level command and deluser a perl script.

To delete a user , just issue command deluser with the username as an argument

sudo userdel username

By default, deluser will remove the user without removing the home directory, the mail spool or any other files on the system owned by the user. Removing the home directory and mail spool can be achieved using the –remove-home option

j@ubuntu2004:~$ sudo deluser --remove-home user01
Looking for files to backup/remove ...
Removing files ...
Removing user `user01' ...
Warning: group `user01' has no more members.
Done.

add or delete user in ubuntu via GUI

If you don’t like command line and your ubuntu has DE like Gnome installed , you definitely can add/delete user in ubuntu using GUI .

There are multiple DEs (desktop environment ) for linux , like Gnome ,KDE XCFE , for ubuntu 20.04 desktop gnome is shipped by default ,so this tutorial will only show you how to add/delete a user in Gnome.

1.From bottom left of your desktop ,click “Show Applications” icon

2.Search “settings” and open it

  1. From left panel , find Users , then click Unlock , you will be prompted to input your sudo password

4.Click the Add User... button

5.You will get a window like below , you can create a new user now

6(Optional) To delete a user from Ubuntu 20.04 , go to the same path as creating a user, then click that Remove User button, you can choose if keep files or not

Conclusion

We’ve showed you how to add and delete user in Ubuntu 20.04 in both command line and GUI.

Feel free to leave a comment if you still have questions.