Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

sudo

lxc

deb

uid

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.

like image 541
Salih Kardan Avatar asked Sep 04 '13 06:09

Salih Kardan


3 Answers

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.

like image 112
Gustavo Matias Avatar answered Oct 21 '22 00:10

Gustavo Matias


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 :-)

like image 15
cnicutar Avatar answered Oct 21 '22 01:10

cnicutar


@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>
like image 2
w39hh Avatar answered Oct 20 '22 23:10

w39hh