欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Chmod 777到一个文件夹和所有内容[重复]

程序员文章站 2022-06-05 14:22:50
...

本文翻译自:Chmod 777 to a folder and all contents [duplicate]

I have a web directory /www and a folder in that directory called store . 我有一个web目录/www和该目录中名为store的文件夹。

Within store are several files and folders. store有几个文件和文件夹。 I want to give the folder store and all files and folders within the store folder all permissions. 我想给文件夹store和中的所有文件和文件夹store文件夹的所有权限。

How do I do this? 我该怎么做呢? I am guessing via .htaccess. 我猜是通过.htaccess。


#1楼

参考:https://stackoom.com/question/YwcL/Chmod-到一个文件夹和所有内容-重复


#2楼

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. 对我来说这是一个有问题的图像所以我去了我的图像文件夹并做了这个。


#3楼

Yes, very right that the -R option in chmod command makes the files/sub-directories under the given directory will get 777 permission. 是的,非常正确的是chmod命令中的-R选项使得给定目录下的文件/子目录将获得777权限。 But generally, it's not a good practice to give 777 to all files and dirs as it can lead to data insecurity. 但一般来说,为所有文件和目录提供777并不是一个好习惯,因为它可能导致数据不安全。 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 ... 将工作


#4楼

for mac, should be a 'superuser do'; 对于mac,应该是'超级用户做';

so first : 首先:

sudo -s 
password:

and then 然后

chmod -R 777 directory_path

#5楼

You can give permission to folder and all its contents using option -R ie Recursive permissions. 您可以使用选项-R即递归权限授予文件夹及其所有内容的权限。

But I would suggest not to give 777 permission to all folder and it's all contents. 但我建议不要给所有文件夹777权限,这是所有内容。 You should give specific permission to each sub-folder in www directory folders. 您应该为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. 第一个数字7 - 用户的读,写和执行。
  • Second Number 5 - Read and execute for the group. 第二个数字5 - 读取并执行该组。
  • 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. 如果您的生产Web文件夹有多个用户,则可以相应地设置权限和用户组。

More info : 更多信息 :

  1. Understanding File Permissions: What Does “Chmod 777″ Mean? 了解文件权限:“Chmod 777”是什么意思?
  2. What file permissions should I set on web root? 我应该在Web根目录上设置哪些文件权限?
  3. Why shouldn't /var/www have chmod 777 为什么不应该/ var / www有chmod 777

#6楼

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