Delete User Account from CentOS / RedHat / Fedora Linux

To delete an existing user from CentOS / RedHat / Fedora Linux, you can use ‘ userdel ‘ command as a root.

The Syntax  to Delete an existing user in Linux:

userdel [options] User_Name

All command line options  used with the ‘userdel’ command are shown below

 ___________________________________________________________________________

     Options                                                                   Description
___________________________________________________________________________
-f, –force                                         force some actions that would fail otherwise
e.g. removal of user still logged in
or files, even if not owned by the user
-h, –help                                          display this help message and exit
-r, –remove                                    remove home directory and mail spool
-R, –root CHROOT_DIR              directory to chroot into
-Z, –selinux-user                          remove any SELinux user mapping for the user
___________________________________________________________________________

 To delete an existing user from server :

If you use ‘ userdel ‘ command without any option , then home directory and mail spool are not deleted.
[root@localhost ~]# userdel a_admin


[root@localhost ~]# ls /home/

a_admin  intzar  noor  Noor

[root@localhost ~]# find /var/spool/ -name a_admin
/var/spool/mail/a_admin

To delete an User from server with home directory with mail spool:

To delete an existing user home directory with mail spool , you can use ‘-r ‘ or ‘–remove’  option with ‘userdel’ command.

[root@localhost ~]# userdel -r Adi

[root@localhost ~]# ls /home
a_admin  intzar  noor  Noor

[root@localhost ~]# find /var/spool/ -name Adi
[root@localhost ~]#

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s