LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 01-14-2010, 04:12 PM   #1
superevilspacemonkey
LQ Newbie
 
Registered: Apr 2008
Location: switzerland
Distribution: OpenSuse 11.2
Posts: 6

Rep: Reputation: 0
Sharing folders between two linux users on same machine (read-write-execute)


Hi LQ users!

I have just set up our home pc with opensuse 11.2 (Awesome!) for shared use between my wife and myself. I have a vague idea how to solve my problem, however I'm certain there are more elegant ways out there..

I would like to share the following folders in my home directory with my wife:
/home/spacemonkey/Pictures
/home/spacemonkey/Music
/home/spacemonkey/Videos

The idea is that we both (and nobody else, not even other members of "users") have access to read, write and excecute these... I have created a new group called "private_users" and added our users to this group...and did the following to the above directories:
Code:
chown -R spacemonkey:private_users <target_dir>
chmod -R 770 <target_dir>
I have created symbolic links in the home folder of my wife to the above directories (as Pictures, Music, Videos) with the following:
Code:
ln -s /home/spacemonkey/Pictures/ Pictures
ln -s /home/spacemonkey/Music/ Music
ln -s /home/spacemonkey/Videos/ Videos
This almost works.. we can read, write and execute all the existing files in these directories, however when we create new files they inherit the default privileges e.g.:
Code:
ls -l
-rw-r--r-- 1 spacemonkey users             2 2010-01-14 22:56 foo
so the other user (eg my wife) will not be able to modify or delete (or excecute)this file...

How do I fix this?

I think that a solution would be to create the following script:
Code:
#!/bin/bash
cd /home/spacemonkey
chown -R spacemonkey:private_users Pictures
chmod -R 770 Pictures
chown -R spacemonkey:private_users Music
chmod -R 770 Music
chown -R spacemonkey:private_users Videos
chmod -R 770 Videos
and then to execute this script with cron every 2 hours or so... I do not actually know how to use cron yet.. Any advice is welcome..

I believe that there must be a much simpler and more elegant solution to this...

Is it possible to make the privileges of the directories persistent and recursive?

Is there a different way of achieving the same?

Thanks for taking the time to read my long post!

br
 
Old 01-14-2010, 05:45 PM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
To set an inherited group on files created within a directory, you can use the sgid bit on the directory permissions:
Code:
chmod g+s Pictures
To make the default file permissions rw for group as well as user, you can change the umask to 0002 (either for all users in /etc/profile, or for individual users in /etc/.bashrc).

However, changing the default permissions will be an issue if all users are in the same default group (ie, on your system it appears to be 'users'), because then all new files will be writable by all members of that group. The default group can be changed using usermod -g. On some distros, the default group is set to the user (eg, files are created spacemonkey:spacemonkey, not as spacemonkey:users), which solves the issue.

Last edited by neonsignal; 01-14-2010 at 05:48 PM.
 
1 members found this post helpful.
Old 01-14-2010, 05:51 PM   #3
forubu
LQ Newbie
 
Registered: Jul 2009
Location: Trondheim, Norway
Distribution: Ubuntu
Posts: 28

Rep: Reputation: 16
First of all you should set the setgid bit on the directories you want to share.
This will make the files you create in these directories inherit the group.
chmod g+s /home/spacemonkey/Pictures (etc.)

Next you will need to edit /etc/fstab and include umask=007 to the home partition.
This will make sure that Others will not have access to the files.
ls -l will show: rwxrwx--- for for all files created on the home partition.

Another option will include installing ACL and setup the home partition to use ACL's.
You will find a lot about ACL's if you google for it.
 
1 members found this post helpful.
Old 01-14-2010, 11:42 PM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
For a Linux filesystem, there isn't a umask= option. That is a samba or fat32 mounting option.
You use "chmod" to change the permissions of a directory. For acls and special attributes, use the mount options "rw,acl,user_xattr" in your /etc/fstab entry for your home partition.

You could set the setguid bit on the directory. I don't know if the underscore is a legal charactor for a group name. I will use "privusers" instead in this example of using facl instead.

Using setfacl, you can create a default acl on the directory. Files created in it will inherit the default. You need to create a normal and a default acl both:

chmod ug=rwx,o= /home/spacemonkey/Pictures
setfacl -m g:privusers:rwx /home/spacemonkey/Pictures
setfacl -m d:g:privusers:rwx /home/spacemonkey/Pictures

You could use u:<wifes_uid>:rwx and d:u:<wifes_uid>:rwx as well. Using facl's you could for example have full permissions for your wife, and read only permissions for your mother in law.

Another option is to create a directory outside of your home directory, E.G. /home/Pictures/. Then you can have 0700 permissions on your home directory. You could both have a symbolic link in your respective home directories pointing to this directory.

Look at the facl manpage, but skip to the bottom for the examples. They are a lot easy to understand and reference.

Last edited by jschiwal; 01-14-2010 at 11:44 PM.
 
1 members found this post helpful.
Old 01-15-2010, 01:47 AM   #5
superevilspacemonkey
LQ Newbie
 
Registered: Apr 2008
Location: switzerland
Distribution: OpenSuse 11.2
Posts: 6

Original Poster
Rep: Reputation: 0
Thumbs up Thanks!

Thanks to everybody for the quick replies!
I will fiddle around over the weekend and post the solution - hopefully not too many questions...
Thanks for taking the time!
 
Old 01-16-2010, 06:36 PM   #6
Borax_Man
Member
 
Registered: Jan 2009
Posts: 31

Rep: Reputation: 16
I'm assuming SpaceMonkey is you.

I don't know why you are sharing folders within your home directory. I would have thought that wouldn't work!

What I would do is simply this.
Go to your /home directory, make one called 'shared'.

Change the permissions on the 'shared' folder, so its owned by you, the new group, and no one else has any access.
Also do a
chmod g+s /home/shared

Create the folers within /home/shared, and make the links as appropriate.
 
1 members found this post helpful.
Old 01-17-2010, 08:14 AM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
They probably have the primary group being users on their home directories with r_x permissions.
 
  


Reply

Tags
chmod, chown, persistant, recursive, sharing



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to share folder (read, write and execute) into the network redline1022 Linux - Networking 3 11-15-2006 01:13 AM
Setting up folders read, read/write? airplaneb777 Linux - Software 1 04-17-2006 08:37 AM
I want my linux machine to read/write to an XP share bjs Linux - Newbie 8 03-26-2004 03:56 PM
How to Read, Write, Execute but not Delete r042wal Linux - Software 6 06-07-2003 11:05 AM
How to set permissions to read, execute, write for users only chupacabra Linux - General 3 12-18-2002 03:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 01:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration