Linux – How to change the root directory for a Linux user

chrootlinuxroot

For a user on a Linux host, I need to make everything inaccessible besides his home directory.

I have heard that this is usually done by changing the root directory for the user (and setting it to the user's home directory), however I couldn't find the way to do it.

I thought about the chroot command, but it seems it just runs the specified command, considering the specified directory as the root directory. So it seems chroot is not what i need.

So my question is: what is the command which changes the user's root directory?

Best Answer

It sounds like you want to change the HOME dir, not the root dir. Root will always be / or /root.

usermod -d /path/to/new/homedir/ username
Related Question