I would like to be able to use the sudo command in a chroot environment.

I start the chroot as follows:

chroot /debian-squeeze /bin/bash

Now I'm logged in as root in the chroot. I can do su user to log in as a user named user. Now, sudo does not work:

user@HD:/$ sudo ls
sudo: must be setuid root

Some diagnostics:

user@HD:/$ which sudo

user@HD:/$ ls -al /usr/bin/sudo
-rwsr-xr-x 2 root root 143884 May 23  2012 /usr/bin/sudo

user@HD:/$ ls -aln /usr/bin/sudo
-rwsr-xr-x 2 0 0 143884 May 23  2012 /usr/bin/sudo

root@HD:/# cat /etc/sudoers
Defaults    env_reset
root    ALL=(ALL) ALL
user ALL=(ALL) ALL
%sudo ALL=(ALL) ALL

As root, I can execute sudo without error.

Can anyone explain me why sudo (or setuid) does not work like this?

  • This page might explain what you are after. Dec 10, 2012 at 2:41
  • @Simplexion I see nothing on that page that might answer this question. Dec 10, 2012 at 3:48
  • 1
    Show output of mount
    – daisy
    Dec 10, 2012 at 3:52

1 Answer 1


My guess is that /debian-squeeze is on a separate filesystem mounted without defaults or suid. The kernel will ignore the setuid bit on filesystems mounted without suid (defaults implies suid). To fix it:

mount -o remount,suid /debian-squeeze
  • If su works than this is not the case...
    – Didi Kohen
    Dec 11, 2012 at 15:06
  • Thanks, this was indeed the solution. (su worked because I was already root user when I executed su.) Dec 12, 2012 at 10:19
  • Be carefull, someone can now go to /debian-squeeze without chroot and use sudo. Jul 15, 2016 at 8:45

You must log in to answer this question.

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