Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do I make a user account using useradd and give the user access to only the dir where he can just read write files. The user when login goes to this base dir I provide and cannot access anything else on the system.Thanks

share|improve this question
add comment

migrated from stackoverflow.com Jun 24 '11 at 16:20

This question came from our site for professional and enthusiast programmers.

2 Answers

A typical user already behaves almost in this fashion -- that is, if you create a user with useradd, that user will only be able to write files in their home directory (and in a few other locations such as /tmp and /var/tmp).

You can't meaningfully prevent them from having read access in a number of places -- for example, the user needs read access to files and directories like /usr/bin. You can substantially limit what is visible to the user by having them run in a chroot environment, but this can be tricky to set up.

You're much better off ensuring that data that shouldn't be visible to arbitrary users is protected by the appropriate permissions.

share|improve this answer
add comment

Rather than setting up a chroot a simpler solution may be to use a restricted shell (such as rbash). See http://man.he.net/man1/rbash and http://blog.bodhizazen.net/linux/how-to-restrict-access-with-rbash/ .

share|improve this answer
add comment

Your Answer

 
discard

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.