• 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

UNIX / Linux : How to delete root equivalent user (Non-Root User with UID 0)

by admin

If you try to delete a user with UID 0 by userdel command, you will get following error.

# id 
uid=0(root) gid=0(root) groups=0(root)
# userdel 
userdel: user user01 is currently used by process 1

All the processes are owned by user IDs and not user-names. So, All process owned by root will be owned by root equivalent user, as they have same UID. To work around this issue follow the steps given below.

Deleting non-root user with UID 0

If you need to delete non-root user having UID 0 (say user01), follow the steps below.

1. Backup the /etc/passwd file.

# cp /etc/passwd /etc/passwd_bkp

2. Open /etc/passwd and change the UID of user01 from 0 to to a UID which is not used by any other user, for example:
change below entry from

user01:x:0:0::/home/user01:/bin/bash

to an entry shown below:

user01:x:2000:0::/home/user01:/bin/bash

3. Now, delete the user with userdel command. This time you should not get any error.

# userdel user01
Note – Never ever try to delete root user or change its UID.

Filed Under: Linux

Some more articles you might also be interested in …

  1. Echo Command with Practical Examples
  2. gacutil: Global Assembly Cache (CAG) management utility
  3. csslint: A linter for CSS code
  4. “git merge-repo” Command Examples
  5. pmap Command Examples in Linux
  6. cockpit-ws Command Examples in Linux
  7. asterisk: command not found
  8. Difference between absolute and relative paths in Linux
  9. RHEL 7 – RHCSA Notes (Cheat Sheets)
  10. setserial: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • gixy Command Examples
  • gitsome Command Examples
  • gitmoji Command Examples
  • gitlint Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright