How to delete the user in Linux Ubuntu ?

If you have existing user and is no longer you need to access the certain user, than you can delete the existing user in simple few steps :

Please Follow the following commands :

you can delete user itself below command.

# deluser username

If you are logged in as another user or non root user than you can follow the following command :

$ sudo deluser username

In case, If you want to remove the users home directory, you can use the following command :

# deluser --remove-home username

If you are logged in as another user or non root user than you can follow the following command to remove the home directory for user :

$ sudo deluser --remove-home username

If you have previously configured the user as sudo users than use following command to remove deleted users form sudo groups.

# visudo

If you are logged in as another user or non root user than use following command :

$ sudo visudo
root ALL=(ALL:ALL) ALL
username ALL=(ALL:ALL) ALL # DELETE THIS LINE

Leave a Reply

Your email address will not be published.Required fields are marked *