Results 1 to 9 of 9

Thread: changing folder permission

  1. #1
    Join Date
    Apr 2009
    Location
    Saitama, Japan
    Beans
    132
    Distro
    Ubuntu 10.04 Lucid Lynx

    changing folder permission

    I am trying to change permission on some folders I have created. However, each time I input the chmod cmd, the file doesn't change. It stays the same. Here is the cmd I used.

    sudo chmod -R 0444 /path/to/my/folder

  2. #2
    Join Date
    Apr 2005
    Location
    Finland/UK
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: changing folder permission

    First, if the directories are something you ave created as your own user, they already belong to that user and there's absolutely no need to use "sudo" in that command. You already have the right to access and modify files and directories you own.

    Anyway, is the directory located on a Windows file system (FAT or NTFS)? Those don't understand ownerships and permissions as they are used in Linux & Unix systems, so you can't set te permissions of individual files or directories on them , instead permissions are applied to the whole file system at the time it's mounted.

    Same goes for any optical medias, the file systems used on those can't handle ownerships and permissions, and are also read-only by definition. So no chown/chmod on CDs or DVDs either...

  3. #3
    Join Date
    Jul 2007
    Location
    Burlington, NC
    Beans
    1,995
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: changing folder permission

    You should never `chmod -R` with number codes!

    This is the probably the #1 piece of bad advice
    that's littered all over the forums and google searches.

    Directories need to be executable but regular files do not.
    There is simply no way to express this with number codes.

    `chmod` has somewhat lesser known symbolic letter codes that are much
    better for use with `-R`. The codes are fairly self explanatory:
    'a+r' means "add Read for All"
    'go-w' means "remove Write for Group and Others"
    'g=u' means "copy User perms. to Group"

    The "magic" letter code that's not immediately obvious is the capital "X"
    This means "execute only for directories and executables*"

    So, the problem with your `chmod -R 0444 ...` is that it will always remove
    executable from all directories. Likewise, `chmod -R 555` is no good because
    it will always add executable to all files. The proper thing to do is this:
    Code:
    chmod -R a+rX,a-w /path/to/folder
    ^Note the capital "X"!!
    This means "Recursively allow Read for All and deny Write for All."

    *The "Wizard Behind the Curtain" that allows the letter codes
    to automagically know when to add execute to programs is that it checks to
    see if the program is already executable by anyone else.

    So, say you have 1 directory with 1 file and 1 executable script.
    And you want to properly allow read/execute to this location for everyone.
    It currently looks like this:
    Code:
    drwxr-x--- folder
    -rw-r----- folder/readme.txt
    -rwxr-x--- folder/script.bash
    The proper command to run is:
    Code:
    chmod -R a+rX folder
    This knows to add execute to "folder" because it is a directory;
    It knows not to add execute to "readme.txt" because it is a plain file;
    and It knows to add execute to "script.bash" because it is already
    executable for the owner. So you end up with this:
    Code:
    drwxr-xr-x folder
    -rw-r--r-- folder/readme.txt
    -rwxr-xr-x folder/script.bash
    ^Perfect!

    I'm not all boring — I use the numeric chmod codes all the time, just not with Recursion!
    Last edited by asmoore82; March 11th, 2011 at 08:55 AM.
    Give me Free Software or Give me Death!

  4. #4
    Join Date
    Apr 2009
    Location
    Saitama, Japan
    Beans
    132
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: changing folder permission

    Thanks for the replys. The folders are from an external hdd and it was mounted FAT32.

  5. #5
    Join Date
    Jan 2008
    Location
    UK
    Beans
    1,783
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: changing folder permission

    I do this the GUI way. Launch Nautilus like this
    Code:
    gksudo nautilus
    Go to the folders where you want to change permissions. Right click then select the Permissions tab. Set the permissions how you want them then close nautilus.

    You're good to go.

    Mark
    Keep Ubuntu free! Donate any amount you like – just use the PayPal donation address donations@ubuntu.com

  6. #6
    Join Date
    Apr 2009
    Location
    Saitama, Japan
    Beans
    132
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: changing folder permission

    It's a server edition. No gui

  7. #7
    Join Date
    Apr 2007
    Location
    Coffee corner
    Beans
    405
    Distro
    Kubuntu 11.04 Natty Narwhal

    Re: changing folder permission

    Quote Originally Posted by duceduc View Post
    The folders are from an external hdd and it was mounted FAT32.
    There's the rub: fat32 doesn't support setting linux-style folder permissions. You can only set permissions partition-wide while mounting. Check this article: http://ubuntu.swerdna.org/ubufat32.html

    Cheers,
    rosencrantz

  8. #8
    Join Date
    Dec 2009
    Beans
    6,771

    Re: changing folder permission

    If you want the whole partition to have what I think was your intent ( 0444 - read only by everyone and not executable ) you're going to have to deviate from swerdna's example:
    UUID=AD74-85CA /path_to/mount_point vfat umask=0000,utf8 0 0
    Something like this I think would be more appropriate:
    UUID=AD74-85CA /path_to/mount_point vfat dmask=0222,fmask=0333,utf8 0 0
    This will make all directories have permissions of 555 - Everyone can open and read the contents of the mount point.

    And all files will have permissions of 444 - Everyone can read but not write or execute.

    The umask parameter for a Windows filesystem is the equivalent of the "-R" option in chmod'ing a Linux file system with number codes. Unlike Linux filesysems all folders and files start out as 777. There's no way to enable the execute bit on folders ( which you must do ) without enabling them on files ( which you do not want to do ) using umask. The dmask / fmask options separate umask into it's directory ( dmask ) and file ( fmask) components.

    Besides we don't want asmoore82 to yell at us again

  9. #9
    Join Date
    Apr 2007
    Location
    Coffee corner
    Beans
    405
    Distro
    Kubuntu 11.04 Natty Narwhal

    Re: changing folder permission

    right, sorry, I was too lazy to adapt it...

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
  •