4

Is it possible to safely downgrade the user 'root', replacing it with a different account name? (say 'admin'). So, in the end, 'admin' would be uid 0 and 'root' 123.

I am using Centos, if that makes any difference. What worries me is if any of the standard services use root hardcoded (cron scripts maybe?) and that causes everything to fail.

Thanks!

john
  • 1,025
  • 3
  • 9
  • 15
  • 2
    Why do you want to do this? – Kyle Smith Apr 06 '12 at 01:02
  • I can't get into the reason as it comes down to corporate data/policies etc., sorry. The end goal is to have 'root' as a limited user. – john Apr 06 '12 at 01:10
  • 2
    I tried renaming the root user on an [SLS](http://en.wikipedia.org/wiki/Softlanding_Linux_System) Linux system many years ago (before Linux 1.0 was even out) just for fun. I didn't create an ordinary user called `root`, just renamed the UID 0 user to `admin`. As I recall, a few minor things broke but most of the system kept chugging along without a problem. – David Schwartz Apr 06 '12 at 01:27

1 Answers1

5

In essence you want to rename the account named root. If you think about it, that's the same as replacing it with a different account (same uid, different name).

Plenty of people will tell you not to, however if you take everything into consideration, it could be done and that without terrible consequences. The trouble comes when an application or script assumes that the root user is named root rather than searching for the root user via uid. I think that's not as much of a problem now as it once was.

What you'll need to do is edit /etc/passwd, /etc/shadow, /etc/group, and /etc/gshadow. From there, the changes will need to be application specific. For instance, for postfix, you'll likely want to grep root in /etc/ and change the aliases to point to the new name.

Other apps will need to be dealt with as needed. For much more info, there's a question over on unix.stackexchange.com titled "How do you rename root?" that has an interesting, CentOS specific answer from someone who sought PCI compliance for his organization by changing the default name for the root account.

P.S. Back everything up twice before you edit your system files.

Wesley
  • 32,690
  • 9
  • 82
  • 117