-   Linux - Newbie (
-   -   Restrict File Access (

dysons 11-25-2009 09:44 AM

Restrict File Access
I need to create e different folders Chunk1, Chunk2 and Chunk3. I then want to have 3 different scripts (or even better one script with 3 different options), the options being...

1) Allow RW access to Chunk1, RO access to Chunk2
2) Allow RW access to Chunk2, RO access to Chunk1
3) Allow RW access to Chunk3, RO access to Chunk2

This is because I will be developing software with one of 3 hats on and I don't want to inadvertently access/edit the wrong file!

Is this easy to do?


lazlow 11-25-2009 09:54 AM

Probably much easier to just make three users (one for each hat) and assign each user to a group with the appropriate permissions.

pcunix 11-25-2009 11:01 AM

So the script would be run as you start work on each project?

Yeah, as lazlow suggested, you could do this with three different users and "su" between them.

Or, you could just "chmod -w", "chmod +w" as desired in your script. It could take the argument of the RW set and act appropriately.

Something like


if [ $1 = "Chunk1" ]
  chmod -R +w Chunk1/*
  chmod R -w Chunk2/*

and so on.

chrism01 11-25-2009 06:37 PM

Yeah, 3 groups/dirs, then use 'newgrp' to change your current primary group on demand.

dysons 11-26-2009 02:24 PM

Thanks for the advice.

Ended up reading through bash script manual and writing a little addition to an existing logon script that calls chmod for aech combination. Seems to work fairly effectively.

I now need to set up 3 eclipse c++ projects (one for each chunk) so that I can edit the source code appropriate to the current 'hat' I am wearing! Not sure how eclipse is going to like to being able to access one of its project areas.

Thanks again.

All times are GMT -5. The time now is 08:30 AM.