Chmod 777 to a folder and all contents

LinuxPermissionsFile PermissionsChmod

Linux Problem Overview


I have a web directory /www and a folder in that directory called store.

Within store are several files and folders. I want to give the folder store and all files and folders within the store folder all permissions.

How do I do this? I am guessing via .htaccess.

Linux Solutions


Solution 1 - Linux

If you are going for a console command it would be:

chmod -R 777 /www/store. The -R (or --recursive) options make it recursive.

Or if you want to make all the files in the current directory have all permissions type:

chmod -R 777 ./

If you need more info about chmod command see: File permission

Solution 2 - Linux

If by all permissions you mean 777

Navigate to folder and

chmod -R 777 .

Solution 3 - Linux

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

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

Each number has meaning in permission. Do not give full permission.

N   Description                      ls   binary    
0   No permissions at all            ---  000
1   Only execute                     --x  001
2   Only write                       -w-  010
3   Write and execute                -wx  011
4   Only read                        r--  100
5   Read and execute                 r-x  101
6   Read and write                   rw-  110
7   Read, write, and execute         rwx  111
  • First Number 7 - Read, write, and execute for the user.
  • Second Number 5 - Read and execute for the group.
  • Third Number 5 - Read and execute for others.

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

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

Solution 4 - Linux

You can also use chmod 777 *

This will give permissions to all files currently in the folder and files added in the future without giving permissions to the directory itself.

NOTE: This should be done in the folder where the files are located. For me it was an images that had an issue so I went to my images folder and did this.

Solution 5 - Linux

Yes, very right that the -R option in chmod command makes the files/sub-directories under the given directory will get 777 permission. But generally, it's not a good practice to give 777 to all files and dirs as it can lead to data insecurity. Try to be very specific on giving all rights to all files and directories. And to answer your question:

chmod -R 777 your_directory_name

... will work

Solution 6 - Linux

for mac, should be a ‘superuser do’;

so first :

sudo -s 
password:

and then

chmod -R 777 directory_path

Solution 7 - Linux

This didn't work for me.

sudo chmod -R 777 /path/to/your/file/or/directory

I used -f also.

sudo chmod -R -f 777 /path/to/your/file/or/directory

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRSMView Question on Stackoverflow
Solution 1 - LinuxpetervazView Answer on Stackoverflow
Solution 2 - LinuxDaniel ElliottView Answer on Stackoverflow
Solution 3 - LinuxSomnath MulukView Answer on Stackoverflow
Solution 4 - LinuxspasticninjaView Answer on Stackoverflow
Solution 5 - LinuxKuldip Singh BehalView Answer on Stackoverflow
Solution 6 - LinuxdukegodView Answer on Stackoverflow
Solution 7 - LinuxJanaka PushpakumaraView Answer on Stackoverflow