How do I change file permissions in Ubuntu [duplic

2019-03-09 05:43发布

In Ubuntu I want to change the file permissions of a whole folder and all its sub folders to read/write by anybody

I have tried sudo chmod 666 /var/www and sudo chmod 755 /var/www without success

update

I have since found that changing privileges can also be done in the GUI by opening nautilus as sudo.

3条回答
女痞
2楼-- · 2019-03-09 06:07

If you just want to change file permissions, you want to be careful about using -R on chmod since it will change anything, files or folders. If you are doing a relative change (like adding write permission for everyone), you can do this:

sudo chmod -R a+w /var/www

But if you want to use the literal permissions of read/write, you may want to select files versus folders:

sudo find /var/www -type f -exec chmod 666 {} \;

(Which, by the way, for security reasons, I wouldn't recommend either of these.)

Or for folders:

sudo find /var/www -type d -exec chmod 755 {} \;
查看更多
一纸荒年 Trace。
3楼-- · 2019-03-09 06:09

Add -R for recursive:

sudo chmod -R 666 /var/www
查看更多
一夜七次
4楼-- · 2019-03-09 06:13

So that you don't mess up other permissions already on the file, use the flag +, such as via

sudo chmod -R o+rw /var/www

查看更多
登录 后发表回答