How To Add and Delete User on Ubuntu From Shell – POFTUT

How To Add and Delete User on Ubuntu From Shell


Linux users can be added with different ways. but one of the most used way is adding them throughout the shell because Linux admins loves shell usage. In this tutorial we will look how to add user into a Ubuntu, Kali, Mint, Debian box and provide or change required parameters. We will also look user deletion.

Root Privileges

In order to add or remove user from a Linux box we need root privileges. We can get root privileges with different ways. We can login to root account like below.

$ su -

OR we can use sudo  command which operates given command with the current user but with root privileges.

$ sudo ls

Add User with adduser

We can use adduser  command in order to add user.  We will add user named poftut . This command will ask user detailes step by step. At the end of the process we will accept adding given user with Yes\no question.

$ sudo adduser poftut
Add User with adduser 
Add User with adduser  

Add User with useradd

useradd is the fastest way to add user. useradd will not look for any user detail. Just add user to the Linux box. But it will not configure any password for the given user so we should set recently added user password with passwd like below. In this test we will add user named test1 and change its password.

$ sudo useradd test2
$ sudo passwd test2
Add User with useradd
Add User with useradd

Delete User

We can easily delete existing user with userdel  command. In the following example we will delete user named test1 . We need root privileges again.

$ sudo userdel test2

LEARN MORE  How To Change User Password with passwd Command In Linux?

1 thought on “How To Add and Delete User on Ubuntu From Shell”

Leave a Comment