0

I am using ubuntu server. My root account uid got changed to 0 to 1, i am not sure when and how. Becausse of this i cant execute any sudo commands on this server. This is what rroot account looks like in /etc/passwd

root:x:1:0:root:/root:/bin/bash

now im in root but i cant do any thing, its behaving like normal user root@server40:/var/log$ id uid=1(root) gid=0(root) groups=0(root)

Please advice me how i can change my root uid 1 to 0. This is production env, so please advice how i can procedd with this. I can get max downtime for 15 min.

Regards, Raj

2
  • simple. you can just edit the file. /etc/passwd. but i would be more concerned which user now has the uid 0. that is which service is using it. i would rather reinstall the whole machine and throw away the harddrives as well.
    – l1zard
    Feb 12, 2015 at 11:15
  • I'm surprised that sudo w/ no username doesn't give you UID 0 but rather the name root.
    – Joshua
    Aug 24, 2016 at 15:24

1 Answer 1

0

Boot from live disk, mount the / (root) partition, edit /etc/passwd (and probably /etc/shadow), save the file and reboot

P.S. And check if there is no other account with ID 0 (which may be indicator of hacked machine)

7
  • Thanks Romeo, this server is running in VM cloud, is it possible to do it in recovery mode?
    – raj
    Feb 12, 2015 at 11:24
  • Then you can just add the live ISO as virtual CD and do the work. But you need access to the console of the machine Feb 12, 2015 at 11:26
  • this is deticated server from fasthost provider. I am not sure how to manage iso image in this vm. is it possible to do it in recovery mode?
    – raj
    Feb 12, 2015 at 11:41
  • IN such case please contact your service provider and ask them Feb 12, 2015 at 11:48
  • 1
    Hi... I have changed root uid by using webmine. webmine allowed to change root uid by using my user id (user should be in sudoers file). So no reboot required if webmin installed.
    – raj
    Feb 12, 2015 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.