简体   繁体   English

Linux-更改除1个目录以外的所有文件和目录的权限吗?

[英]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.

相关问题 如何在Linux中的所有子目录上强制CURRENT目录权限? - How to force CURRENT directory permissions on all sub-directories in Linux? 使用find - 删除除任何一个之外的所有文件/目录(在Linux中) - Using find - Deleting all files/directories (in Linux ) except any one 在Linux脚本中,如何删除当前目录中的所有文件和目录? - In a Linux script, how to remove all files & directories but one, in current directory? Linux:如何删除目录本身(不是子目录)内的所有文件(不是目录) - Linux: How to delete all of the files (not directories) inside a directory itself (not childs) 在Linux终端中,如何删除目录中除一个或两个以外的所有文件 - In Linux terminal, how to delete all files in a directory except one or two 如何更改 Linux 目录中文件的默认权限? - How to change default permissions for files inside a directory in Linux? 为 Linux 目录下新创建的文件和子目录设置默认权限? - Setting default permissions for newly created files and sub-directories under a directory in Linux? 如何更改 linux 上包含特定字符串的所有目录/文件的名称 - how to change names of all directories / files containing a specific string on linux .txt 文件显示目录和子目录的内容及其所有文件和目录权限 - .txt file shows contents of directory and sub-directories and all of their files and directory permissions linux ksh如何删除除最新目录以外的所有目录 - linux ksh how to remove all directories except the latest some directories
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM