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”


[[email protected]:/]# chmod 0751 /home
[[email protected]:/]# 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


[[email protected]:/]# chmod 0751 jordan
[[email protected]:/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!


Did you like this article?


0 Shares:
You May Also Like

Screenshot Tour: Customize Windows XP with TweakUI

LifeHacker Has a walk through of how to customize Microsoft Windows XP with Tweak UI, with included screen shots.
Customize Windows XP with TweakUI - One of the best tools for fine-tuning Windows XP is the free TweakUI PowerToy utility from Microsoft. TweakUI digs deep into Windows' settings and can customize its behavior dozens of ways, from how many icons appear on the Alt-Tab dialog to Explorer context menu choices to what your program shortcuts look like. TweakUI's been around forever and we've mentioned it here and there throughout the years at Lifehacker, but it's high time we gave it the full walk-through it deserves. After the jump, take a gander at 15 useful adjustments you can make to your XP system with TweakUI.
Read More

Windows Live Photo Gallery 2008 12.0.1193.815 Beta

Microsoft is pumping out more free software for the masses. I've never heard or seen Windows Live Photo Gallery, but I thought about downloading and installing this application to give it a whirl. During the install, I asked to install a bunch more Windows Live applications. Specifically the Mail component, since my MSN account is attached to my Hotmail. After installing everything, I ran the Windows Live Photo Gallery, and it was pretty amazing.
Read More