简体   繁体   English

Linux默认文件权限

[英]Linux default file permission

Is there someway to set the default file permission in Linux? 有没有办法在Linux中设置默认文件权限? That is, the file permission for a newly created file (regardless of the context for which it was created ). 也就是说,新创建的文件的文件权限(不管创建它的上下文)。 I know about putting umask in the shell startup but that only works for shell sessions. 我知道将umask放在shell启动中,但这只适用于shell会话。 When I transfer files to a Linux box using pscp , the file is always created with permissions of 664 (rw-rw-r--). 当我使用pscp将文件传输到Linux机器时,始终使用664(rw-rw-r--)的权限创建该文件。 The has occurred across every flavor of Linux that I've used. 我曾经使用过各种Linux版本。 This is especially annoying when I pscp a file to shared Linux machine (like my ISP). 当我将文件pscp到共享Linux机器(如我的ISP)时,这尤其令人讨厌。 Until I can shell in and chmod the permission, the file is basically sitting there with read access for everyone, which is not exactly secure. 直到我可以shell并chmod权限,该文件基本上坐在那里,每个人都有读取权限,这不完全安全。

Put the umask in the non-interactive shell startup ( .bash_profile , .zshenv , .tcshrc depending on your shell). 将umask放在非交互式shell启动( .bash_profile.zshenv.tcshrc具体取决于您的shell)。 Then it'll run for non-login sessions. 然后它将运行非登录会话。

如果要影响整个系统,还可以将其放在/ etc / profile中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM