• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

userdel: command not found

by admin

The userdel command is used to delete user accounts. By default, it does not delete the user’s home directory unless you use the -r option. Deleting the user account removes all references to it. You would have to recreate the account and re-add it to groups in order to resemble the original identity. Use caution before deleting a user account.

Syntax

The syntax of the userdel command is:

$ userdel [options] {user names}
  • userdel [username]: This removes the user entry from the /etc/passwd file, but leaves the user’s home directory and mail intact. This way of deleting a user account is not recommended.
  • userdel -r [username]: This removes the user and the user’s home directory, along with the user’s mail box. This will remove the files owned by the user along with the user’s account from his home directory.

If you encounter below error while running the userdel command:

userdel: command not found

you may try installing the passwd package as shown below as per your choice of distribution.

Distribution Command
Debian apt-get install passwd
Ubuntu apt-get install passwd
Alpine apk add shadow
Arch Linux pacman -S shadow
Kali Linux apt-get install passwd
Fedora dnf install shadow-utils-2
Raspbian apt-get install passwd

userdel Command Examples

1. Remove a user:

# userdel username

2. Remove a user in other root directory:

# userdel --root path/to/other/root username

3. Remove a user along with the home directory and mail spool:

# userdel --remove username

Filed Under: Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL 7 : Beginners guide to systemd
  2. journalctl Command Examples in Linux
  3. CentOS / RHEL : DNS servers in /etc/resolv.conf change after a reboot/network service restart. How to make them permanent
  4. grub-bios-setup: command not found
  5. fail2ban-client: command not found
  6. Sample /etc/services file in Linux
  7. IBM DB2 Installation on Red Hat Enterprise Linux
  8. CentOS / RHEL : How to block incoming and outgoing ports using iptables
  9. CentOS / RHEL 7 : How to change the verbosity of debug logs during booting
  10. Linux / UNIX : How to find files which has SUID/SGID set

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright