Chmod 777 to a folder and all contents

2,830,474

Solution 1

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

If by all permissions you mean 777

Navigate to folder and

chmod -R 777 .

Solution 3

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

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

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

Share:
2,830,474
RSM
Author by

RSM

Updated on January 13, 2022

Comments

  • RSM
    RSM over 2 years

    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.

  • Somnath Muluk
    Somnath Muluk almost 8 years
    Why downvote? Is it wrong answer? Downvoter please explain so that I can improve quality of answer.
  • Marijke Luttekes
    Marijke Luttekes over 7 years
    I haven't downvoted, but I think the reason is that your answer does not cover the OPs question. It's still a good answer, just not for this topic.
  • Somnath Muluk
    Somnath Muluk over 7 years
    @MarijkeLuttekes: There are already answers who are giving light on how to give 777 permissions to folder. That's not my intention to answer. I am saying not to give 777 permission to folder at all to www folder. See first comment for question of anubhava. Instead give 755 or required permissions. We understand sometimes from question that OP is heading in wrong direction. Then we should give path should be followed. It's not only OP will be requiring solution. With same question another person will come to this page for finding answer, then that person will understand what this answer.
  • Loligans
    Loligans over 7 years
    This should be marked the correct answer. While the other answers give the 'solution' to the problem, this one explains how a typical folder structure should be setup. Very rarely if ever would you want to make a web folder 777. Read the More info links that @SomnathMuluk has provided so that you can understand why.
  • xxjjnn
    xxjjnn over 7 years
    and if you have a symlink to said folder, to change the permissions on the symlink do chmod -h 777 /some_path/symlink
  • DanoPlurana
    DanoPlurana over 5 years
    Nope, doesn't work on Ubuntu. New files appear to have different permissions than the ones that were already in the directory.
  • FerdousTheWebCoder
    FerdousTheWebCoder about 5 years
    after reading it, i think, 754 is a good choice, also
  • JayRizzo
    JayRizzo over 4 years
    +1 by far the best delivery I have seen of the binary permissions in an answer! Thanks for this easy on the eyes breakdown!
  • Mingtao Sun
    Mingtao Sun over 4 years
    Sometimes you need to add sudo to make it work. sudo chmod -R 777 /www/store
  • Henke
    Henke over 3 years
  • user3751385
    user3751385 about 3 years
    Note chmod -R 777 /some/path will fail silently if your target is a one of the following file systems: NFTS / exFAT / FAT32
  • alper
    alper over 2 years
    Does it also cover all the hidden files?
  • alper
    alper over 2 years
    Does it also cover all the hidden files staring with . like .git/?
  • alper
    alper over 2 years
    -f is not force thought it just suppress most error messages
  • Ali Ganjbakhsh
    Ali Ganjbakhsh about 2 years
    I think, by putting -r, it recursively covers all files in the directory.