What happens if you delete the root user?

5,462

You can't delete an user if there are processes currently running as that user, which in the case of root, is always. You could manually delete the entries in /etc/{passwd,shadow,group}, but depending on the settings in /etc/nsswitch.conf, there might be alternate sources of the root account, so things will continue to work. If you then remove the alternate sources in /etc/nsswitch.conf so that only these files are used (by keeping only compat):

passwd: compat
group: compat
shadow: compat

Then things will start to break:

$ sudo -i
sudo: unknown user: root
sudo: unable to initialize policy plugin

It might even lead to an unbootable system; you'll have to go back and fix with a live USB or single user mode.

Share:
5,462

Related videos on Youtube

NerdOfLinux
Author by

NerdOfLinux

Updated on September 18, 2022

Comments

  • NerdOfLinux
    NerdOfLinux over 1 year

    What happens if you run

    sudo deluser root
    

    will sudo still work, and will the system still work?