Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I just installed a 32-bit chroot to run on my 64-bit system. In the chroot environment, the sudo command doesn't work, it says

sudo: command not found

Also, when I try the su root command, my password doesn't work (su: authentication failure). What password do they want?

I'm quite new to Ubuntu, so actually I don't really know what I'm doing. I am just trying to follow instructions.


I solved this particular problem simply by starting the chroot by the command:

katarina@ubuntu:~$ schroot -c oneiric_i386 -u root

instead of the one I used the first time:

katarina@ubuntu:~$ schroot -a

I still have some other problems, but I guess that's not for this question.

share|improve this question

4 Answers 4

In my opinion the question is more about not understanding what chroot does.

It moves the / to wherever you tell it, so there's no more /bin, /sbin, or /usr.

This means you're not going to have sudo anymore since it lives in one of those directories.

share|improve this answer

When you start a chroot environment, you are generally already root, so you don't need to use sudo or su root.

If you need to use a non-root user account, you need to create it first, and login as that user with (in the chroot)

login myuser

or

su - myuser

Next, if you want to let that user to use sudo, you need to add it to the admin group into the chroot.

share|improve this answer
    
I see. No I want to use the root-account. But if I skip the sudo it sais permission denied: (oneiric_i386)katarina@ubuntu:~$ apt-get install vim E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? –  katarina Apr 10 '12 at 12:07
    
@katarina: but this command is run inside the chroot? Have you issued the chroot /path command? –  enzotib Apr 10 '12 at 12:35
    
yes cause I couldn't find an editor in the chroot environment. I don't know wht you mean by the chroot /path command, what does it do? Sorry this is new to me. –  katarina Apr 10 '12 at 13:41
    
@katarina: I suggest to review your chroot information with the following page Basic chroot. –  enzotib Apr 10 '12 at 13:53

There's more to it than you think to get a working chroot jail. In your example, it's because the sudo command is in /bin and not available in your new root. But just installing the base packages to the new root won't do the trick, you also need to mount a /proc, /sys and /dev for the jail, probably create a couple of symbolic nodes, definitely a tty and for most practical purposes, it probably won't work without a random too. You do that with mknod.

Now all that sounds complicated, and to be honest, it is a bit involved. Debian based distros have a simpler way of dealing with it, namely, debootstrap, for which you can find a basic how-to tutorial in the Ubuntu help site.

share|improve this answer
    
I think you forgot to mention sudoers? –  SamB Nov 29 '13 at 6:11
    
@SamB Should be automagically created by installing the sudo package to the new root. –  TC1 Nov 29 '13 at 10:17

You must install sudo in the chroot'ed environment:

apt-get install sudo
share|improve this answer

Your Answer

 
discard

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.