[英]Linux - Change permissions of all files & directories except 1 directory?
This has stumped me for a bit now after working on it for a while. 经过一段时间的研究,这让我有些难过。 I need to change the permission settings of all files and directories so that group and others have no read, write, or execute access except for one specific directory.
我需要更改所有文件和目录的权限设置,以便除一个特定目录外,组和其他人没有读取,写入或执行访问权限。 So far I have tried variations of `
到目前为止,我已经尝试过`
chmod go-rwx | chmod go+rwx 'filename'
Any tips?` 有什么提示吗?
I don't believe there's a solution shorter than a 2 steps pipeline. 我认为没有比2步流水线短的解决方案了。
Otherwise, you might want to check umask. 否则,您可能要检查umask。 umask changes the default permissions on a file on creation (sadly only on file created by the same shell, but you can add this to the .bash_rc/.bash_profile, so that every shell you'll open will do this by default)
umask会在创建时更改文件的默认权限(主要是对同一外壳程序创建的文件的默认权限,但是您可以将其添加到.bash_rc / .bash_profile中,以便默认情况下,您打开的每个外壳程序都将执行此操作)
umask 077
will set the mask so that every new file will have permissions like 700. So you might want to just use this so that in the future you won't need to re-launch that pipeline. 将设置掩码,以便每个新文件都将具有700的权限。因此,您可能只想使用它,以便将来无需重新启动该管道。
EDIT if the problem was the pipeline itself, then I'd do 编辑如果问题是管道本身,那么我会做
cd && chmod -R 700 && cd 'path/to/that/directory' && chmod -R 777
with the double '&' instead of the pipe just because there's not output to pipe, so an && might do the trick 用双'&'代替管道,只是因为没有输出到管道,所以&&可以解决问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.