• 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

How to delete a non-root use with UID 0 in Linux

by admin

This pos describes how to delete a non-root user with UID zero. If you try to delete a user with UID 0 by userdel command, you will get the following error.

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

If you need to delete non-root user having UID 0 (say user1), follow these steps:

1. Backup the /etc/passwd file before proceeding:

# cp /etc/passwd /etc/passwd.bkup

2. Open /etc/passwd and change the UID of user1 from 0 to a UID which is not used by any other user:

user1:x:0:0::/home/scom:/bin/bash

For example:

user1:x:1111:0::/home/scom:/bin/bash

Give a higher number for the new UID and make sure you do not specify standard UIDs.

3. Now, delete the user:

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

Filed Under: Linux

Some more articles you might also be interested in …

  1. git describe: Give an object a human-readable name based on an available ref
  2. Linux OS Service ‘kudzu’
  3. gem: Interact with the package manager for the Ruby programming language
  4. balooctl Command Examples in Linux
  5. “cannot install the best update candidate for package” – error on running dnf update
  6. How to Enable Debug Mode for Chronyd Service in CentOS/RHEL 8
  7. fstrim Command Examples in Linux
  8. lsns: command not found
  9. nmcli networking Command Examples
  10. How to Rebuild the “initramfs” with Multipath in CentOS/RHEL 6 and 7

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