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

raj
  • 1
  • 1
  • 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 '15 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 '16 at 15:24

1 Answers1

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)

Romeo Ninov
  • 5,319
  • 5
  • 20
  • 20
  • Thanks Romeo, this server is running in VM cloud, is it possible to do it in recovery mode? – raj Feb 12 '15 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 – Romeo Ninov Feb 12 '15 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 '15 at 11:41
  • IN such case please contact your service provider and ask them – Romeo Ninov Feb 12 '15 at 11:48
  • Thanks Romeo. I have checked with them now. they can insert CD in this server. But i have doubt, have to insert live ubuntu CD or installation CD? If live CD, can you please tell me procedure? – raj Feb 12 '15 at 12:01
  • You are welcome. As far as i remember install CD can act as live too. But you can run any live CD for the purpose – Romeo Ninov Feb 12 '15 at 12:08
  • 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 '15 at 14:34