How can I remove a Linux user account from Linux system. As you know user management in Linux requires root privileges. While removing user his home directory can be remove or preserved. As same with mail box. User mailbox can be preserved.
Check Account Existence
Before removing or deleting an user account checking the existing of account can be useful. We can check wheter given account exist with different ways. In this example we will use
chage command with
-l list option for user
$ chage -l ismail
chage: user 'ismail' does not exist in /etc/passwd
- chage will give information about specified user
- -l test will list users information
- As said before the user is removed so there is no information about the user.
We will remove only user without removing user files.
Remove Only User Account with userdel Command
We can remove given user account with
userdel command like below. In this example we will remove user account named
ismail . As this is an administrative task we need root privielges which can be get with
$ sudo userdel ismail
- userdel will remove specified test user account
Remove Only User Account Line From passwd File
We have an other less structured option to remove a user account. We can remove the line which user is defined from file
/etc/passwd . As this file contains user details this will remove user account. We can also remove password hash from