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

Lets say I boot up my computer and I see the login screen. When I log in as myuser, I want to be restricted to a certain root directory via. chroot.

Let's assume that the directory is /chroots/myuser/. Is this possible to do ? If so, how would it be accomplished ?

Just to be clear, I want to change the root directory, not the home directory. The new root directory for the user will contain another OS like Debian.

share|improve this question
up vote 6 down vote accepted

Change the user's default shell in /etc/passwd to the command (or a wrapper script for that command) that logs that user into the chroot.

share|improve this answer
I think maybe you will then want a separate /etc/password inside the chroot which lists bash, see eg. here: olivier.sessink.nl/jailkit/howtos_ssh_only.html – goldilocks Jan 14 '13 at 12:58
@goldilocks I use schroot which has a -s flag, with which you can set the shell for the user that you log in as. It also updates the user in /etc/passwd to use that shell (in the chroot environment). – user1973386 Jan 14 '13 at 16:16

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.