How to change Permission of a folder in Mac/Linux/Unix

Using chmod command you can change Permission of a folder in Mac/Linux/Unix. If you are going for a console command it would be:


 chmod -R mode /path/to/folder


 chmod -R 777 /www/store

You can give permission to the folder and all its contents using option -R  i.e Recursive permissions.

Each number have meaning in permission. Do not give full permissions.

N   Description                      ls   binary    0   No permissions at all            ---  0001   Only execute                     --x  0012   Only write                       -w-  0103   Write and execute                -wx  0114   Only read                        r--  1005   Read and execute                 r-x  1016   Read and write                   rw-  1107   Read, write, and execute         rwx  111
  • First Number 7 – Read, write, and execute for user.
  • Second Number 5 – Read and execute for group.
  • Third Number 5 – Read and execute for other.

But I would suggest not to give 777 permission to all folder and it’s all contents. You should give specific permission to each sub-folder in www directory folders.

Ideally, give 755 permission for security reasons to the web folder.

sudo chmod -R 755 /www/store

If your production web folder has multiple users, then you can set permissions and user groups accordingly.

For Apache permissions, you’re going to want to stick to 0755 and 0644 (AKA umask 022) for folders and files respectively. This allows you, as the owner of the files, to edit and manipulate them while giving Apache the bare minimum levels of access needed to operate.

More info

  1. Understanding File Permissions: What Does “Chmod 777″ Mean?
  2. What file permissions should I set on web root?
  3. Why shouldn’t /var/www have chmod 777