Delete User on Centos Redhat RHEL Fedora

Delete User on Centos Redhat RHEL Fedora 

delete users on Linux

On Linux (CentOS Redhat RHEL Fedora), we can use command “userdel” to delete user account on Linux.

Command:

userdel username

Option 1: Delete user

[root@localhost ~]# userdel kevin

Option 2: Delete user and User’s home directory

[root@localhost ~]# userdel -r kevin

Before deleting any user, we should review these steps:

1. Find any file or folder which that username is owner before we start to delete that Username (Optional)

[root@localhost ~]# find / -user kevin -print
find: `/proc/6465/task/6465/fd/5′: No such file or directory
find: `/proc/6465/task/6465/fdinfo/5′: No such file or directory
find: `/proc/6465/fd/5′: No such file or directory
find: `/proc/6465/fdinfo/5′: No such file or directory
/var/spool/mail/kevin
/home/kevin
/home/kevin/.mozilla
/home/kevin/.mozilla/plugins
/home/kevin/.mozilla/extensions
/home/kevin/.gnome2
/home/kevin/.bash_profile
/home/kevin/.bashrc
/home/kevin/.bash_logout
/root/Desktop/ciscovpn
/root/Desktop/ciscovpn/manifesttool
/root/Desktop/ciscovpn/license.txt
/root/Desktop/ciscovpn/vpnagentd_init
/root/Desktop/ciscovpn/AnyConnectProfile.xsd
/root/Desktop/ciscovpn/VPNManifestClient.xml
/root/Desktop/ciscovpn/AnyConnectLocalPolicy.xsd
/root/Desktop/ciscovpn/vpndownloader
/root/Desktop/ciscovpn/libssl.so.0.9.8
/root/Desktop/ciscovpn/vpn_uninstall.sh
/root/Desktop/ciscovpn/vpnui
/root/Desktop/ciscovpn/vpn
/root/Desktop/ciscovpn/VeriSignClass3PublicPrimaryCertificationAuthority-G5.pem
/root/Desktop/ciscovpn/libcrypto.so.0.9.8
/root/Desktop/ciscovpn/vpn_install.sh
/root/Desktop/ciscovpn/vpnagentd
/root/Desktop/ciscovpn/anyconnect.desktop
/root/Desktop/ciscovpn/update.txt
/root/Desktop/ciscovpn/pixmaps
/root/Desktop/ciscovpn/pixmaps/systray_disconnecting.png
/root/Desktop/ciscovpn/pixmaps/cvc-configure.png
/root/Desktop/ciscovpn/pixmaps/systray_notconnected.png
/root/Desktop/ciscovpn/pixmaps/cvc-disconnect.png
/root/Desktop/ciscovpn/pixmaps/cvc-info.png
/root/Desktop/ciscovpn/pixmaps/systray_quarantined.png
/root/Desktop/ciscovpn/pixmaps/company-logo.png
/root/Desktop/ciscovpn/pixmaps/cvc-about.png
/root/Desktop/ciscovpn/pixmaps/systray_connected.png
/root/Desktop/ciscovpn/pixmaps/vpnui48.png
/root/Desktop/ciscovpn/pixmaps/systray_reconnecting.png
/root/Desktop/ciscovpn/pixmaps/cvc-connect.png
/root/Desktop/ciscovpn/AnyConnectProfile.tmpl
[root@localhost ~]#

2. Backup user’s home folder which you want to delete (Optional).

[root@localhost tmp]# tar -zcvf /tmp/kevin.tar.gz /home/kevin/
tar: Removing leading `/’ from member names
/home/kevin/
/home/kevin/.mozilla/
/home/kevin/.mozilla/plugins/
/home/kevin/.mozilla/extensions/
/home/kevin/.gnome2/
/home/kevin/.bash_profile
/home/kevin/.bashrc
/home/kevin/.bash_logout
[root@localhost tmp]#

Thanks for using IThelpblog.com.

 

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>