26

I am trying to create deb package from LXC rootfs, and after creating it I want to install that package any computer. Up to this point I achieved packaging and installing deb package, however after installation of LXC package, I cannot be superuser in that lxc. I get this error when I use "sudo" command.

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

thanks in advance.

Salih Kardan
  • 579
  • 1
  • 5
  • 16

5 Answers5

64

I just had this same exact problem on Mac OS after strangely deciding to screw my own system by doing: sudo chmod -R /usr/bin. If that's someone else's case just open Disk Utility, select your OS disk ("Macintosh HD" in my case), go to First Aid tab then hit Repair Disk Permissions, wait a few and things should get fixed.

Gustavo Matias
  • 3,088
  • 2
  • 21
  • 26
15

Your sudo binary doesn't have the setuid flag, as it correctly guessed. As root, try:

chmod u+s /usr/bin/sudo

OSX users:

To everyone landing here from search engines: this is not the way to fix the OSX system that you broke. The question is Linux oriented - hint, lxc tag - and that is what this answer is for. The answer provided by Gustavo Matias might help :-)

cnicutar
  • 164,886
  • 23
  • 329
  • 361
  • 5
    I get the message: chmod: changing permissions of ‘/usr/bin/sudo’: Operation not permitted – Jimmy Knoot Oct 23 '13 at 08:44
  • 1
    this solution is not working for me getting: 'chmod: changing permissions of ‘/usr/bin/sudo’: Operation not permitted' Also I am getting '-rwxrwxrwx 1 root root 121144 Feb 28 2013 /usr/bin/sudo' when I run ls -l `which sudo` – abhishek Jan 09 '14 at 13:46
  • @holyredbeard Check the tags on this question again. This is not an OSX specific question and as such there is nothing OSX specific in my answer :-) – cnicutar Apr 23 '14 at 19:26
  • I accidentally messed /usr/bin permission and you saved me to reinstall my CentOS server. Thanks a lot! – Drake Dec 14 '15 at 12:25
  • @cnicutar How does this work? If I run the command without `sudo`, it tells me I don't have permission, and if I run it with `sudo`, it gives me the same "effective uid is not 0..." error (I'm using Amazon Linux). – tarrball Feb 12 '16 at 14:27
2

@cnicutar has provided the answer

On a Ubuntu 14.04 host, the following worked

    Exit the container
    Stop the container

Now that you are on the host, set the flag

sudo chmod u+s /var/lib/lxc/<container_name>/rootfs/usr/bin/sudo

Check the flag

sudo ls -l /var/lib/lxc/<container_name>/rootfs/usr/bin/sudo
-rwsr-xr-x 1 root root ... ... var/lib/lxc/<container_name>/rootfs/usr/bin/sudo

Start your container and enter the console You should be able to execute

sudo apt-get install <package>
w39hh
  • 21
  • 1
1

This error can also be caused by the use of jailed ssh shell for the user. Try un-restricting the shell session if this is the case.

ejectamenta
  • 913
  • 13
  • 19
0

I had this proplem today,and I solved this by run following command with root

chmod u+s /usr/bin/sudo

I hope it will help you !

iwwenbo
  • 21
  • 4