How to restrict users in linux to their home directory

So lets say you have a server with a bunch of users and they all have sites and data and you don’t want them to be able to see each others data. A lot of distributions aren’t setup to stop users from wandering and reading files within other users directories.

So lets say you have a server with a bunch of users and they all have sites and data and you don’t want them to be able to see each others data. A lot of distributions aren’t setup to stop users from wandering and reading files within other users directories.

What you will need to do is change the permissions on the /home and each users directory using chmod. So first we need to change the permission on “/home”


[root@taco:/]# chmod 0751 /home
[root@taco:/]# stat home
File: `home'
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 900h/2304d Inode: 2 Links: 32
Access: (0751/drwxr-x--x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2007-12-03 13:58:07.000000000 -0800
Modify: 2007-11-21 12:10:17.000000000 -0800
Change: 2007-12-03 13:57:28.000000000 -0800

As you can see the folder is now set to 0751, depending you may want to change this but by default this should be fine.

Now you need to change the permission on each users directory using chmod yet again


[root@taco:/]# chmod 0751 jordan
[root@taco:/home]# stat jordan
File: `jordan'
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 900h/2304d Inode: 19709953 Links: 15
Access: (0751/drwxr-x--x) Uid: ( 1000/ jordan) Gid: ( 1000/ jordan)
Access: 2007-12-03 12:14:23.000000000 -0800
Modify: 2007-11-14 11:06:38.000000000 -0800
Change: 2007-12-03 13:57:42.000000000 -0800

Now your users shouldn’t be able to see other users on your system!

0 Shares:
You May Also Like

Nokia N810 gets official

The new N810 by Nokia was announced this morning, the following is some of its features as well as a picture of its pull and slide qwerty keyboard. A much bigger phone, but with a screen this size and a faster processor and more ram this phone is definitely going to be on a few peoples wish list.

Bitcoin Miner

Purchased 2x Sapphire 5830’s and a 1000W OCZ refurb. More from my siteDIY “beatbox” drives old neighbors crazyUniversal Network Boot…

P2P Remains Dominant Protocol

P2P Remains Dominant Protocol - An anonymous reader writes "Last week, a press release was issued by Ellacotya that suggested something quite startling — HTTP (Hyper Text Transfer Protocol, aka Web traffic) had for the first time in four years overtaken P2P traffic. However a new article from Slyck disputes this, and contends that P2P remains the bandwidth heavyweight."

Read more of this story at Slashdot.

[Slasdot]