LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-12-2008, 06:11 AM   #1
powerpleb
LQ Newbie
 
Registered: Apr 2008
Location: Melbourne, Australia
Distribution: Arch, Ubuntu 8.04
Posts: 27

Rep: Reputation: 15
Creating a group home directory


I want to create a directory in /home that several users can access so I can put shared files in there (Music, Photos, Videos, etc)
I was thinking I could create a group called 'share' and a directory called /home/share and set it up so members of the group have full access to this directory.
So my questions are...
Do all directories in /home have to be user accounts, ie if I create /home/share will Linux want to create a user called 'share'?
Can groups have /home folders?
Is /home a good place to be storing shared files?

I ask this because I have /home on a large partition and it would be nice to have users' files and shared files kept on the same partition.

Last edited by powerpleb; 06-12-2008 at 06:14 AM.
 
Old 06-12-2008, 06:29 AM   #2
ranger_nemo
Senior Member
 
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 47
Your plan is pretty much spot-on... /home is the best place for user data files.

No, your system won't require you to create a user to make a new directory in /home. You can create all the subdirectories you want.

The one stumbling point might be adding new files and subdirectories to /home/share... When you first create it and stuff a bunch of files in there, you will have use chown to change the ownership of the directory and files to the group. If user bob adds more files later, they should be readable by other users, but they might not be writable. You might want to look into Samba or NFS to share the folder to the users, because those programs can take care of file permissions automatic'ly.
 
Old 06-12-2008, 06:42 AM   #3
powerpleb
LQ Newbie
 
Registered: Apr 2008
Location: Melbourne, Australia
Distribution: Arch, Ubuntu 8.04
Posts: 27

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by ranger_nemo View Post
You might want to look into Samba or NFS to share the folder to the users, because those programs can take care of file permissions automatic'ly.
So that means I can use NFS to both share it with users on the same machine and users connecting to that machine over LAN. Bloody brilliant.
 
Old 06-12-2008, 07:44 AM   #4
zQUEz
Member
 
Registered: Jun 2007
Distribution: Fedora, RHEL, Centos
Posts: 294

Rep: Reputation: 53
As mentioned, you are basically doing this correctly.
To handle the permissions, you can change the permissions like this:
1) create a folder: mkdir /home/shared
2) make a shared group name in /etc/group
3) make all the users that need access to this shared location, members of the shared group.
4) change the ownership on the shared folder: chown root:shared /home/shared
5) change the perms on the shared folder again: chmod 770 /home/shared
6) apply the guid on the shared folder: chmod g+s /home/shared

Now when new files are added to this folder, no matter who adds them, they will have a group owner the same as the folder owner - e.g. shared. As the group owner has r/w capabilities, they will be able to modify.
 
Old 06-12-2008, 09:27 AM   #5
ranger_nemo
Senior Member
 
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 47
Cool... A sticky group. You learn something new every day.
 
Old 06-12-2008, 05:23 PM   #6
powerpleb
LQ Newbie
 
Registered: Apr 2008
Location: Melbourne, Australia
Distribution: Arch, Ubuntu 8.04
Posts: 27

Original Poster
Rep: Reputation: 15
Thanks, that's brilliant.

As directed by someone on another forum I ended up hiding the folder by naming it /home/.share
Then I put symlinks into users' accounts like this:
Code:
ln -s /home/.share /home/user1/share
 
Old 09-06-2012, 07:24 PM   #7
Michael Scheper
LQ Newbie
 
Registered: Mar 2010
Posts: 2

Rep: Reputation: 0
Lightbulb Perhaps a more elegant solution?

Ubuntu comes with an /etc/profile that includes this:

Code:
if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi
It should work with any distro, though, and I've successfully created a file called /etc/profile.d/group.sh and given it group read permissions. The script then gets run for members of that group only.

To set the permissions for the script, type:

Code:
sudo chmod 750 /etc/profile.d/group.sh
sudo chown root:group /etc/profile.d/group.sh
If your /etc/profile doesn't already contain the first block of code, you should be able to just copy it in. But I'd replace the -r with -x, thus making it depend on group execute permissions, which is technically more correct. The code to type above would remain the same.

Last edited by Michael Scheper; 09-06-2012 at 07:25 PM. Reason: to clarify why I'd replace -r with -x
 
Old 09-07-2012, 12:42 AM   #8
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
Just to be pedantic
Quote:
they will have a group owner the same as the folder owner
should read
Quote:
they will have a group owner the same as the folder group owner
 
  


Reply

Tags
groups, home, shared


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
home directory & group question katkota Linux - Software 1 01-05-2008 08:37 PM
Useradd not creating home directory when creating newuser meneedham Linux - Newbie 4 10-05-2007 12:11 PM
Problem creating a home directory for users Ruffian2001 Fedora 3 04-28-2007 05:21 PM
creating home directory jitheshmurali Linux - Networking 2 04-24-2006 06:03 AM
Creating new user gives empty /home directory rkfb Slackware 8 12-28-2005 11:17 AM


All times are GMT -5. The time now is 07:05 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration