How to delete a user in linux



Step 1: Delete the User

userdel myuser

If you want to remove all of the files for the user, then use -r:

userdel -r myuser

Step 2: Remove Root Privileges to the User

visudo

Find the following code:

## Allow root to run any commands anywhere
root ALL=(ALL) ALL
myuser ALL=(ALL) ALL


In this case, we’re removing root privileges from the user mynewuser . Remove the following:

myuser ALL=(ALL) ALL

Then exit and save the file with the command :wq .


How can I delete a user in linux when the system says its currently used in a process


First use pkill or kill -9 <pid> to kill the process.

Then use following userdel command to delete user,

userdel -f cafe_fixer

 
According to userdel man page:

-f, --force

This option forces the removal of the user account, even if the user is still logged in. It also forces userdel to remove the user's home directory and mail spool, even if another user uses the same home directory or if the mail spool is not owned by the specified user. If USERGROUPS_ENAB is defined to yes in /etc/login.defs and if a group exists with the same name as the deleted user, then this group will be removed, even if it is still the primary group of another user.

Comments

Popular posts from this blog

Android App Version Update using the following cordova cli commands

75 inspirational quotes that will change your life

Retrieval Image From DataBase and Display on WebPage by Using Servlets.