Linux chmod 777 到一个文件夹和所有内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8328481/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Chmod 777 to a folder and all contents
提问by RSM
I have a web directory /www
and a folder in that directory called store
.
我有一个 web 目录/www
和一个名为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.
里面store
有几个文件和文件夹。我想为文件夹store
以及文件夹中的所有文件和文件store
夹授予所有权限。
How do I do this? I am guessing via .htaccess.
我该怎么做呢?我猜测通过 .htaccess。
采纳答案by petervaz
If you are going for a console command it would be:
如果您要使用控制台命令,它将是:
chmod -R 777 /www/store
. The -R
(or --recursive
) options make it recursive.
chmod -R 777 /www/store
. 该-R
(或--recursive
)选项使其递归的。
Or if you want to make all the files in the current directory have all permissions type:
或者,如果您想让当前目录中的所有文件都拥有所有权限,请键入:
chmod -R 777 ./
chmod -R 777 ./
If you need more info about chmod
command see: File permission
如果您需要有关chmod
命令的更多信息,请参阅:文件权限
回答by Daniel Elliott
If by all permissions you mean 777
如果所有权限都是指 777
Navigate to folder and
导航到文件夹和
chmod -R 777 .
回答by spasticninja
You can also use chmod 777 *
你也可以使用 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.
注意:这应该在文件所在的文件夹中完成。对我来说,这是一个有问题的图像,所以我去了我的图像文件夹并执行了此操作。
回答by Kuldip Singh Behal
Yes, very right that the -R
option in chmod
command makes the files/sub-directories under the given directory will get 777permission. But generally, it's not a good practice to give 777to 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:
是的,非常正确,命令中的-R
选项chmod
使给定目录下的文件/子目录将获得777权限。但一般来说,将777赋予所有文件和目录并不是一个好习惯,因为它会导致数据不安全。尝试非常具体地授予所有文件和目录的所有权限。并回答你的问题:
chmod -R 777 your_directory_name
... will work
... 将工作
回答by dukegod
for mac, should be a ‘superuser do';
对于 mac,应该是“超级用户做的”;
so first :
所以首先:
sudo -s
password:
and then
进而
chmod -R 777 directory_path
回答by Somnath Muluk
You can give permission to folder and all its contents using option -R
i.e Recursive permissions.
您可以使用选项(-R
即递归权限)授予文件夹及其所有内容的权限。
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.
但我建议不要给所有文件夹和所有内容都授予 777 权限。您应该为 www 目录文件夹中的每个子文件夹授予特定权限。
Ideally, give 755
permission for security reasons to the web folder.
理想情况下,755
出于安全原因,授予Web 文件夹权限。
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.
- 第一个数字 7 - 为用户读取、写入和执行。
- 第二个数字 5 - 为该组读取和执行。
- 第三个数字 5 - 为他人阅读和执行。
If your production web folder has multiple users, then you can set permissions and user groups accordingly.
如果您的生产 Web 文件夹有多个用户,那么您可以相应地设置权限和用户组。
More info :
更多信息 :
回答by Janaka Pushpakumara
This didn't work for me.
这对我不起作用。
sudo chmod -R 777 /path/to/your/file/or/directory
I used -f
also.
我-f
也用过。
sudo chmod -R -f 777 /path/to/your/file/or/directory