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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • 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. asar – A file archiver for the Electron platform (Command Examples)
  2. Understanding /etc/group file
  3. “shutdown” Command Examples in Linux
  4. ltrace Command Examples in Linux
  5. dmidecode: command not found
  6. arecord Command Examples in Linux
  7. w Command Examples in Linux
  8. numactl: command not found
  9. netstat: command not found
  10. mount Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • glab Command Examples
  • “glab repo” Command Examples
  • “glab release” Command Examples
  • “glab pipeline” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright