How can i set new user home root path without permission of getting path 'backwards' on Centos 7

I created a new user "newuser2" as below with /home as a root but this user can still browse "backwards" into the system.

adduser --home /home/newuser2 newuser2

How can i allow this user browsing only within its root folder?


Solution 1:

Any standard user can browse the directory tree. What comes to using options - check the man pages. You'd have known that the option --home has no other effect but setting the location of the user's home directory, in case you don't want it to be /home/$USER.

For restricting you could for example set their login shell to /bin/rbash instead of /bin/sh or /bin/bash. Again, check the man page for options. Also test till you're satisfied.