Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: default folder permissions

  1. #1
    Join Date
    Oct 2005
    Location
    Connecticut, USA
    Beans
    1,575
    Distro
    Ubuntu 16.04 Xenial Xerus

    Arrow default folder permissions

    Running Ubuntu 10.04 LTS and Gnome, I have a Shared folder (/home/SHARE) that I want my wife and I to have read/write permissions to while the kids have read-only access. We both are part of the same group ("Parents") which, obviously, the kids are not.

    The problem is when my wife saves a file in some level of this directory it saves it with her as the owner and her default group as the group. Most often we are placing pictures in albums under /home/SHARE/Pictures/ with digiKam from our digital camera.

    I don't have write access to these files (and vice verse, when I put a file into any subdirectory, she doesn't have write access) until I run
    Code:
    sudo chown <username>:Parents -R /home/SHARE 
    # makes all files have "Parents" as their group
    
    sudo chmod 775 -R /home/SHARE 
    # makes all files have read/write access for the owner and members of the "Parents" group, 
    # all else gets only read-only access
    So how do I get it so when files are saved here they automatically are saved with the specified group and with a chmod of 775 (owner/group has full access, others have read-only)?
    Last edited by Dragonbite; November 29th, 2010 at 09:36 PM.
    Friends don't let friends wear a red shirt on landing-party duty.
    DACS | Connecticut LoCo Team | My Blog
    Ubuntu User# : 17583, Linux User# : 477531

  2. #2
    Join Date
    Oct 2005
    Location
    Connecticut, USA
    Beans
    1,575
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: default folder permissions

    Running a script may work, except I need to be in sudo (or root) and I'm not sure how to do that automatically.
    Friends don't let friends wear a red shirt on landing-party duty.
    DACS | Connecticut LoCo Team | My Blog
    Ubuntu User# : 17583, Linux User# : 477531

  3. #3
    Join Date
    May 2010
    Location
    uk
    Beans
    9,374
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: default folder permissions

    Hi

    Take a look at

    http://www.linuxforums.org/articles/...ssions_94.html

    at the section

    Setting the SGID attribute on a directory : chmod g+s


    Kind regards
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

  4. #4
    Join Date
    Oct 2005
    Location
    Connecticut, USA
    Beans
    1,575
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: default folder permissions

    Thanks! That is great stuff (dangerous, but great)!

    So I did set up all of the children of this directory with the "parent" group and used chmod g+s for the entire directory.
    Code:
    sudo chgrp  parents -R /home/SHARE
    sudo chmod g+s -R /home/SHARE
    Now I need to look up more on umask and see if I can use that to set the permissions automatically for -rwxrwxr-- (owner & group get read-write, all others get read-only) for this directory only.

    Thanks again!
    Friends don't let friends wear a red shirt on landing-party duty.
    DACS | Connecticut LoCo Team | My Blog
    Ubuntu User# : 17583, Linux User# : 477531

  5. #5
    Join Date
    Oct 2005
    Location
    Connecticut, USA
    Beans
    1,575
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: default folder permissions

    While I'm not quite sure about the numbering process for umask, it sounds like what I need to do is
    Code:
    #umask 002 /home/SHARE
    and this will modify the umask ONLY for the directory. The "0" is full permissions while "2" I believe is read-only. The default global umask is "022" which means owner-only can modify their files ("0") while everybody else has read-only ("2").

    I'll try this at home and see if this works.

    Does anybody have any experience with "umask"? I've used it, without fully understanding it, when mounting some external drive. Now I know to be a little more careful about this but if this works it will be great!
    Friends don't let friends wear a red shirt on landing-party duty.
    DACS | Connecticut LoCo Team | My Blog
    Ubuntu User# : 17583, Linux User# : 477531

  6. #6
    Join Date
    Apr 2010
    Location
    England
    Beans
    3,286

    Re: default folder permissions

    umask is a way of restricting permissions. You understand the way that octal works with chmod, right? e.g. 7 = rwx, 5 = r-x, 0 = ---, etc.

    Well umask works the opposite way, and restricts the permissions that would be granted with the chmod equivalent. So 7 takes away read write and execute, 5 takes away read and execute, and 0 doesn't restrict permissions at all.

    So, if a person creates a file in a folder with the umask 057, then the permissions on the file will be -rwx-w---- (more or less, execute is usually left off of new files). I believe the umask on Ubuntu is 022, which creates files with -rwxr-xr-x.
    http://xkcd.com/293/
    There are 10 kinds of people in this world: Those who understand ternary, those who don't, and those who confuse it with binary.

  7. #7
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: default folder permissions

    A umask cannot be specified on a per-directory.

    You could use bindfs to remount the directory with permission settings.

    HowTo: Create a shared directory for local users (with bindfs).

  8. #8
    Join Date
    Oct 2005
    Location
    Connecticut, USA
    Beans
    1,575
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: default folder permissions

    Here's another question then; is there anything wrong with setting the umask for the system to "002"?

    What I am thinking is that "002" means owner/group has r+w while other has r only.

    In Ubuntu, each user is usually set up by default with their own (default) group so their files will be owner/group as r+w, but since they are the only person in the group it effectively means they are the only one that can access those files.

    Then, when files are saved in this /home/SHARE location where the group "parents" is automatically assigned, the people in the "parents" group has full access while everybody else has read-only.

    Is there a security issue, or potential danger of setting it up as such? I know it will REQUIRE that each person has their own group, but that's pretty easy to do.
    Friends don't let friends wear a red shirt on landing-party duty.
    DACS | Connecticut LoCo Team | My Blog
    Ubuntu User# : 17583, Linux User# : 477531

  9. #9
    Join Date
    Jul 2006
    Beans
    4,807

    Re: default folder permissions

    Quote Originally Posted by Dragonbite View Post
    While I'm not quite sure about the numbering process for umask, it sounds like what I need to do is
    Code:
    #umask 002 /home/SHARE
    and this will modify the umask ONLY for the directory.
    I'm about 99% positive it's all or nothing.

    AKA, system-wide or nothing. No such thing as per directory umask settings in this case. I would LOVE it if that were the case but... doesn't appear to be that way.

  10. #10
    Join Date
    Apr 2010
    Location
    England
    Beans
    3,286

    Re: default folder permissions

    There's nothing wrong with changing the system-wide umask. It won't change the permissions on already existing files, and most system files are owned by root:root anyway. However, I'm not sure whether installed files adhere to umask or not, but it's probably best not to touch the "others" umask value.

    You can set the default umask in /etc/profile. This value can be changed on a per-user basis by adding "umask ###" to their ~/.bash_profile (assuming they use bash as their shell).
    http://xkcd.com/293/
    There are 10 kinds of people in this world: Those who understand ternary, those who don't, and those who confuse it with binary.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •