ltd*_*dev 5 linux permissions command-line file-permissions chmod
使用单个命令创建文件/目录时可以设置权限吗?还是必须先创建文件/目录,然后使用 chmod 设置其权限?
例如做这样的事情
// for directories
mkdir 755 test
// for files
touch 644 test/my_file.php
Run Code Online (Sandbox Code Playgroud)
对于文件,尝试使用install命令:
$ install -m 644 /test/path/ myfile.php
Run Code Online (Sandbox Code Playgroud)
对于文件夹,mkdir带有-m参数:
$ mkdir -m 755 test
Run Code Online (Sandbox Code Playgroud)
您可能必须将其执行为sudo.