It would be the right thing to say that I messed up!

Accidentally, I changed the owner of all files in /usr/bin to 'dev' from 'root'. Now, sudo does not work! If I use sudo with any command, I get -

sudo: effective uid is not 0, is sudo installed setuid root?

I cannot use chown command to change the owner back to 'root'. This is a major set back!

Because this is a Virtual Machine, I cannot access the Recovery Console. Infact, even the reboot command needs the user to have 'root' access.

Experts, please help me in getting control of the OS without having to re-image.


P.S - Possibly a duplicate but reposting as his solution was to start afresh.

More info -

su - root always says incorrect password. Unfortunately, the owner of su is also 'dev'.

I am able to create a new user using the GUI. It accepted the root password. How do I grant the new user with root access without using visudo.

  • Are you able to use vi ?
    – Sreeraj
    May 19, 2016 at 7:46
  • Yes @Sreeraj, I am able to use vi
    – Swanidhi
    May 19, 2016 at 7:47
  • 1
    If you changed owner of su, then you're out of luck. What does which su says?
    – user140866
    May 19, 2016 at 8:09
  • @siblynx it says /bin/su. The owner of su is also 'dev'
    – Swanidhi
    May 19, 2016 at 8:10
  • 1
    No it's not possible because only root can change privileged bits on executables. If anyone would, then system would be completely insecure.
    – user140866
    May 19, 2016 at 8:59

2 Answers 2


Physical security is security. You have three options:

  1. Log in as root, either from the console or by ssh.
  2. Boot in single-user mode, which traditionally doesn't need the root password (but might on your system).
  3. Mount the disk image from another OS.

Any of these will give you the ability to change the ownership of any file on the disk. If none of them is an option for you, you're out of luck, but you're also not in control: other things -- that aren't mistakes -- can happen that require console access.

  • Incidentally, checking root pw in single user is done in a way that doesn't care about suid binaries.
    – Joshua
    Aug 6, 2019 at 20:07

I can't say anything for sure without spinning up a VM and imitating your situation, but what I'd probably do is, if you can have a file act as external media for your VM, boot up a Live CD/USB distro (Knoppix, or the default archiso, or the Gentoo install CD, or Porteus) and then do something like mounting the filesystem with the broken /usr/bin (perhaps using cd /; mkdir /backup; cp /mnt/centos/usr/bin /backup, copying over the binary files you want to save and chown -hR 0 /backup; chmod 755 them or whatever your chosen privileges for /usr/bin are, then deleting the /usr/bin in only the broken stuff (if the fs to be fixed was mounted at /mnt/centos, the command to use for the last instruction would be rm -r /mnt/centos/usr/bin) then something among the lines of cp /backup /mnt/centos/usr/bin And that might work. Don't do this yet though, since I still haven't spun up a VM to test this. If you can't make a file act as an external bootable medium, then I think you need to reinstall, after making a backup of all files you want to save. I hope this answer serves you well.

  • Also, it might be possible to just use the bootable external medium and just chown -hR /mnt/centos/usr/binthe thing. Also, is your system one where /bin is linked to /usr/bin (similar to Debian 11 and recent releases of Fedora) or are they different directories? May 13, 2021 at 1:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .