Chmod 777到一个文件夹和所有内容

时间:2021-01-05 00:30:59

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.

在存储中有几个文件和文件夹。我想给文件夹存储以及存储文件夹中的所有文件和文件夹所有权限。

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

我该怎么做呢?我是通过。htaccess猜的。

7 个解决方案

#1


518  

If you are going for a console command it would be: chmod -R 777 /www/store. The -R makes it recursive.

如果要使用控制台命令,应该是:chmod -R 777 /www/store。r是递归的。

#2


116  

If by all permissions you mean 777

如果所有权限都是777。

Navigate to folder and

导航到文件夹,

chmod -R 777 .

#3


52  

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.

但是我建议不要给777权限给所有的文件夹,它是所有的内容。您应该为www目录文件夹中的每个子文件夹授予特定的权限。

Ideally give 755 permission for security reasons to web folder.

sudo chmod -R 755 /www/store

Each number have meaning in permission. Do not give full permissions.

每个数字都有其意义。不要给予完全的权限。

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 user.
  • 第7 -为用户读、写和执行。
  • Second Number 5 - Read and execute for group.
  • 第二个数字5 -读取并执行组。
  • Third Number 5 - Read and execute for other.
  • 第三个数字5 -读取和执行其他。

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

如果您的产品web文件夹有多个用户,那么您可以相应地设置权限和用户组。

More info

更多信息

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

#4


22  

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.

注意:这应该在文件所在的文件夹中完成。对我来说,这是一个有问题的图像所以我去我的图像文件夹做了这个。

#5


7  

for mac, should be a ‘superuser do’;

对于mac来说,应该是一个“超级用户”;

so first :

首先:

sudo -s 
password:

and then

然后

chmod -R 777 directory_path

#6


6  

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 its not a good practice to give 777 to all files and dirs as it can lead to data in-security. Try to be very specific on giving the all rights to all files and directories. and to answer your question:- chmod -R 777 your_directory_name will work.

没错,chmod命令中的-R选项使给定目录下的文件/子目录获得777权限。但通常情况下,给所有文件和数据提供777不是一个好的做法,因为它会导致数据处于安全状态。尽量把所有文件和目录的所有权限都指定给它。要回答你的问题:- chmod - r777 your_directory_name可以。

Kuldip Singh Behal

辛格Kuldip理论

#7


2  

This didn't work to 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

#1


518  

If you are going for a console command it would be: chmod -R 777 /www/store. The -R makes it recursive.

如果要使用控制台命令,应该是:chmod -R 777 /www/store。r是递归的。

#2


116  

If by all permissions you mean 777

如果所有权限都是777。

Navigate to folder and

导航到文件夹,

chmod -R 777 .

#3


52  

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.

但是我建议不要给777权限给所有的文件夹,它是所有的内容。您应该为www目录文件夹中的每个子文件夹授予特定的权限。

Ideally give 755 permission for security reasons to web folder.

sudo chmod -R 755 /www/store

Each number have meaning in permission. Do not give full permissions.

每个数字都有其意义。不要给予完全的权限。

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 user.
  • 第7 -为用户读、写和执行。
  • Second Number 5 - Read and execute for group.
  • 第二个数字5 -读取并执行组。
  • Third Number 5 - Read and execute for other.
  • 第三个数字5 -读取和执行其他。

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

如果您的产品web文件夹有多个用户,那么您可以相应地设置权限和用户组。

More info

更多信息

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

#4


22  

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.

注意:这应该在文件所在的文件夹中完成。对我来说,这是一个有问题的图像所以我去我的图像文件夹做了这个。

#5


7  

for mac, should be a ‘superuser do’;

对于mac来说,应该是一个“超级用户”;

so first :

首先:

sudo -s 
password:

and then

然后

chmod -R 777 directory_path

#6


6  

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 its not a good practice to give 777 to all files and dirs as it can lead to data in-security. Try to be very specific on giving the all rights to all files and directories. and to answer your question:- chmod -R 777 your_directory_name will work.

没错,chmod命令中的-R选项使给定目录下的文件/子目录获得777权限。但通常情况下,给所有文件和数据提供777不是一个好的做法,因为它会导致数据处于安全状态。尽量把所有文件和目录的所有权限都指定给它。要回答你的问题:- chmod - r777 your_directory_name可以。

Kuldip Singh Behal

辛格Kuldip理论

#7


2  

This didn't work to 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