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.

1 Answer 1


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.

  • 2
    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, 2013 at 12:58
  • 2
    @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). Jan 14, 2013 at 16:16

You must log in to answer this question.

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