0

I accidentally ran this command chmod -R 755 /usr/bin on my remote server [Ubuntu 12.04.3 LTS], and I don't have the root password.

When I run sudo it gives me sudo: must be setuid root, This is the /bin folder permissions

drwsr-xr-x   2 deployer root 40960 juil. 23 11:54 bin

SSH connexion is the only access I have to my remote server.

ayb
  • 3
  • that setup looks really strange, can you post an ls -al /bin/chmod? Is it +s as well? – noleti Jul 23 '14 at 13:48
  • for ls -al /bin/chmod-rwxr-xr-x 1 root root 51760 nov. 19 2012 /bin/chmod – ayb Jul 23 '14 at 13:53
  • Ok, so no +s unfortunately. But sudo is not owned by root any more? How did you manage that? can you add ls -al /usr/bin/sudo? The directory properties you currently have are not that interesting. – noleti Jul 23 '14 at 13:55
  • for ls -al /usr/bin/sudo -rwxrwxr-x 2 deployer root 71288 févr. 27 2013 /usr/bin/sudo – ayb Jul 23 '14 at 13:58
  • 3
    ... that was certainly not the result of chmod -R 755 /usr/bin. Without root password, and without option to boot into recovery console or boot from USB, I say your system is screwed. – noleti Jul 23 '14 at 14:01
  • This is a hard way to learn a lesson, but generally speaking, it is a bad idea to change ownership and permissions of system files and the end result is almost always system breakage as you can see. You are going to have to obtain physical access and boot to recovery mode (root shell) to fix this or re-install. I suggest you read https://help.ubuntu.com/community/RootSudo and https://help.ubuntu.com/community/FilePermissions – Panther Jul 23 '14 at 17:07
  • Thanks for your help, yes this hard way to learn :/ – ayb Jul 23 '14 at 23:03

1 Answers1

2

Your error message is caused by sudo being owned by deployer, in addition, the rights are set incorrectly. To fix the permissions, try something like chmod 4755 /usr/bin/sudo, as you own sudo currently.

To fix the ownership, you need to run chown root:root /usr/bin/sudo ...but you might need to be root for that. Unless you have +s set on /bin/chown, and without root password or recovery console/alternative boot method, there is probably no way. So, you can try the above chown command with your normal user, but most likely you will have to re-install.

More similar questions:

Error after sudo-ing "sudo: must be setuid root"

sudo: must be setuid root

noleti
  • 4,053
  • 27
  • 25
  • Thanks for accepting the answer. Were you able to fix the setup with chown? Can you update your question with the Info I asked for in the comments? – noleti Jul 23 '14 at 23:12
  • When i ran 'chown root:root /usr/bin/sudo' it gives ...Operation not allower. I think i will re-install the systeme, – ayb Jul 23 '14 at 23:20