Setting permissions on Mac OS X

5,086

Solution 1

#cd to the root folder
cd /
#list folders
ls -al
#you will see "Applications" there ...
cd Applications/application_name/your/folder/and/subfolder
#you can autocomplete with <tab> for available folders
#when you are in the desired folder:
chmod 777 ./
#you can use -R option to chmod to apply it recursively

Solution 2

Try using the symbolic options to chmod instead. You may find it more intuitive.

$ cd Applications/application_name/your/folder/and/subfolder
$ chmod -R a+rX .

Working backwards through the args to chmod:

  • . means use the current directory
  • a+rX means add (+) read permission (r) and execute/access permission (X) for all users (a). The capital X means only add execute permission if another user already has execute/access permission -- this will grant it to directories (x means access permission for directories). I don't think there's a numeric equivalent for capital X.
  • -R means do this recursively -- i.e. repeat for all subdirectories and subdirectories in those, etc

Note randomly making things 777 is generally bad idea. You're opening up files to be written or executed. Some files need to be writeable -- e.g. wordpress is easier to work with if the web server can update certain files.

Share:
5,086

Related videos on Youtube

YsoL8
Author by

YsoL8

Updated on September 17, 2022

Comments

  • YsoL8
    YsoL8 almost 2 years

    I am developing a website hosted locally on a Mac and I am having trouble with directory permissions.

    I have exhausted my normal options for solving the problem and the remaining solution I can think of is to try setting permissions in the terminal. I've never used the terminal seriously and I hoping someone could give me directions to do this.

    What I need to do:

    Direct terminal to hard-drive/Applications/MAMP/htdocs/mysite/myfolder/mysubfolder

    ( Ls -l doesn't return Applications which is confusing).

    Set the permissions there to the terminal version of 777

    If someone could guide me though that, I'll scribble it down and never forget it!

    I tried:

    oliver-nourishs-mac-mini:/ oliver$ cd Applications/MAMP/htdocs/barbadoslettings
    oliver-nourishs-mac-mini:barbadoslettings oliver$ chmod 777 ./
    oliver-nourishs-mac-mini:barbadoslettings oliver$ cd images
    oliver-nourishs-mac-mini:images oliver$ chmod 777 ./
    oliver-nourishs-mac-mini:images oliver$ cd carhire
    oliver-nourishs-mac-mini:carhire oliver$ chmod 777 ./
    oliver-nourishs-mac-mini:carhire oliver$ 
    

    in relation to the original answer, but my permissions still seem stuck.

  • KeithB
    KeithB almost 14 years
    If any of the folders have spaces in the names, you either put a backslash in front of the space, or enclose the entire path in quotes (").
  • YsoL8
    YsoL8 almost 14 years
    OK will try this and come back shortly
  • YsoL8
    YsoL8 almost 14 years
    what does recursive mean in context?
  • YsoL8
    YsoL8 almost 14 years
    See what I tried in the original question
  • Chealion
    Chealion almost 14 years
    @YsoL8: Recursively means it will apply to every file and folder contained in the folder you're telling to change the permissions for. When you run ls -l in one of those folders it won't tell you the permissions of that folder. ls -la will - look for rwxrwxrwx before the single period where the filename is.
  • Patkos Csaba
    Patkos Csaba almost 14 years
    In your original attempt you changed only the permissions on the current folder, not on the contents of it. ./ means current folder. If you append -r (recursive) it will change the permissions on the current folder and on all it's files and subfolders and the files from the subfolders and so on. If you want to change the permission only on the files from the current folder, without affecting the folder itself, use chmod 777 ./*, where * (star) means all files matching any name.