• 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

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. UNIX / Linux : How to delete root equivalent user (Non-Root User with UID 0)
  2. How to obtain virtual/physical CPU information in Oracle VM (XEN)
  3. Sample /etc/multipath.conf file
  4. How to set nproc (Hard and Soft) Values in CentOS / RHEL 5,6,7
  5. Linux OS Service ‘squid’
  6. CentOS / RHEL : How to add a null route in Linux
  7. ldconfig Command Options
  8. Dependency failed for NFS server and services
  9. How to move /var on a separate disk as a separate mount point (Online)
  10. Change default kernel (boot with old kernel) – CentOS/RHEL/OEL 7

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright