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

KDE 4 Beta 3 – Screenshot Tour

A rather in-depth screenshot tour of the new KDE 4 beta 3 booted from a LiveCD.
Stephan Binner has released a new version of his KDE Four Live CD. This version uses a recent SVN snapshot and works quite well. While I had some trouble testing the newest KDE 4 Beta release on my test machine, the KDE Four LiveCD works surprisingly well. According to Stephan the version used on this LiveCD is KDE 4 Beta 3 plus a set of recent patches.
See the full Screenshot tour
Read More

Microsoft Pleads With Consumers to Adopt Vista Now

I for one am currently at torn between XP and Vista. I like XP because it doesn't crash, my drivers work. However, more people keep asking for help with Vista, and I haven't even logged into a Vista Machine yet. :(
Microsoft Pleads With Consumers to Adopt Vista Now - SlinkySausage writes "Microsoft has admitted, in an email to the press, that 'some customers may be waiting to adopt Windows Vista because they've heard rumors about device or application compatibility issues, or because they think they should wait for a service pack release.' The company is now pleading with customers not to wait until the release of SP1 at the end of the year, launching a 'fact rich' program to try to convince them to 'proceed with confidence'. The announcement coincides with an embarrassing double-backflip: Microsoft had pre-briefed journalists that it was going to allow home users to run Vista basic and premium under virtual machines like VMWare, but it changed its mind at the last minute and pulled the announcement."

Read more of this story at Slashdot.

[Slasdot]
Read More

Novell and RedHat Linux vs IP Innovation LLC: Was Ballmer right?

A good read from Groklaw, it goes on about the the current filed Patent Infringement Claim put forth by IP Innovation LLC.
Patent Infringement Lawsuit Filed Against Red Hat & Novell - Just Like Ballmer Predicted IP Innovation LLC has just filed a patent infringement claim against Red Hat and Novell. It was filed October 9, case no. 2:2007cv00447, IP Innovation, LLC et al v. Red Hat Inc. et al, in Texas. Where else? The patent troll magnet state. The first ever patent infringement litigation involving Linux. Here's the patent, for those who can look at it without risk. If in doubt, don't. Here's the complaint [PDF].
Read More

EA Games wants an Open and Single Platform

EA Games Head of International Distribution Florin, wants a single and open platform. Instead of having 3 or 4 different platforms for each game they release, they want to stream line it. He also goes on to talk about set top boxes and how they will be the next generation console.
Read More