• 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. Dependency failed for NFS server and services
  2. mkfs.btrfs Command Examples in Linux
  3. iwctl: command not found
  4. fdisk: Unable to write /dev/sdg: Bad file descriptor – error while formatting USB disk
  5. mountpoint: command not found
  6. How to Convert PuTTY’s private key (.ppk) to SSH key
  7. How to Configure Multiple MySQL Servers On One System Using mysqld_multi
  8. zypper: command not found
  9. LVM Configuration : Logical Volume (LV) Operations/Utilities
  10. dmidecode Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright