Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
This page might explain what you are after. – Simplexion Dec 10 '12 at 2:41
@Simplexion I see nothing on that page that might answer this question. – Michael Hampton Dec 10 '12 at 3:48
Show output of mount – warl0ck Dec 10 '12 at 3:52
up vote 4 down vote accepted

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
share|improve this answer
If su works than this is not the case... – David Kohen Dec 11 '12 at 15:06
Thanks, this was indeed the solution. (su worked because I was already root user when I executed su.) – math1985 Dec 12 '12 at 10:19
Be carefull, someone can now go to /debian-squeeze without chroot and use sudo. – richard Jul 15 at 8:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.