Server Fault is a question and answer site for system and network administrators. 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 need a user with specific homefolder. This user should read and write in his folder. And he cant read any other folder in the server.

share|improve this question
What OS? People are answering based on assumptions but assumptions are the mother of all stuff-ups. – John Gardeniers May 28 '11 at 12:13
up vote 2 down vote accepted

There are two possible ways of achieving this.

The first is to build a chroot environment for that user. To do that it is required that you build a new root with all the necessary binaries, libs and such for that user to work. It is quite complicated and especially if you are somewhat new to using *nix.

If you only require that the user has access to the files that can be done through SFTP if you use an OpenSSH version above 4.9 without any extra add-ons or modifications. I have written a blog post on this subject here:

share|improve this answer

To add a user just use the following command

adduser <username>

As for how to restrict them to their home directory hopefully the answers to this question will help

share|improve this answer

The best method to bind a user to his home directory is to use "rbash" which stands for "restricted" bash. Using this, not only the user won't have any permissions to other directories but his home. He won't be able to change directory to elsewhere (cd /root will be denied, for example)

To do this, open /etc/passwd with root access using any editor (vi, vim or nano) after the user and his/her home directory are created. Find the line which contains the user record and simply replace /bin/bash with /bin/rbash

share|improve this answer

To add a user with home folder you can use this command (on ubuntu):

useradd -d /home/username -m username
passwd username 
share|improve this answer
That's not what he is asking. – Frands Hansen May 28 '11 at 11:17

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.