Chmod 777 to a folder and all contents
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 :
- Understanding File Permissions: What Does “Chmod 777″ Mean?
- What file permissions should I set on web root?
- 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
RSM
Updated on January 13, 2022Comments
-
RSM over 2 years
I have a web directory
/www
and a folder in that directory calledstore
.Within
store
are several files and folders. I want to give the folderstore
and all files and folders within thestore
folder all permissions.How do I do this? I am guessing via .htaccess.
-
Somnath Muluk almost 8 yearsWhy downvote? Is it wrong answer? Downvoter please explain so that I can improve quality of answer.
-
Marijke Luttekes over 7 yearsI 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 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 over 7 yearsThis 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 over 7 yearsand if you have a symlink to said folder, to change the permissions on the symlink do
chmod -h 777 /some_path/symlink
-
DanoPlurana over 5 yearsNope, doesn't work on Ubuntu. New files appear to have different permissions than the ones that were already in the directory.
-
FerdousTheWebCoder about 5 yearsafter reading it, i think, 754 is a good choice, also
-
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 over 4 yearsSometimes you need to add sudo to make it work.
sudo chmod -R 777 /www/store
-
Henke over 3 years
-
user3751385 about 3 yearsNote
chmod -R 777 /some/path
will fail silently if your target is a one of the following file systems: NFTS / exFAT / FAT32 -
alper over 2 yearsDoes it also cover all the hidden files?
-
alper over 2 yearsDoes it also cover all the hidden files staring with
.
like.git/
? -
alper over 2 years
-f
is not force thought it just suppress most error messages -
Ali Ganjbakhsh about 2 yearsI think, by putting -r, it recursively covers all files in the directory.