我可以在使用单个命令创建文件/目录时设置权限,还是必须先创建文件/目录然后使用chmod设置其权限?
例如做这样的事情
// for directories
mkdir 755 test
// for files
touch 644 test/my_file.php
答案 0 :(得分:3)
手册页是你的朋友。这可以使用GNU mkdir但不能使用GNU touch。
mkdir -m 755 test
答案 1 :(得分:3)
对于文件,请尝试使用WITH
t4 AS (SELECT n FROM (VALUES(0),(0),(0),(0)) t(n))
,t256 AS (SELECT 0 AS n FROM t4 AS a CROSS JOIN t4 AS b CROSS JOIN t4 AS c CROSS JOIN t4 AS d)
,t16M AS (SELECT ROW_NUMBER() OVER (ORDER BY (a.n)) AS num FROM t256 AS a CROSS JOIN t256 AS b CROSS JOIN t256 AS c)
SELECT
DATEADD(day, CAST(CAST(NEWID() AS varbinary(1)) AS int) % 3, '20150103') AS Date
,DATEADD(millisecond, CAST(CAST(NEWID() AS varbinary(4)) AS int), CAST('' AS time)) AS Time
,(CAST(CAST(NEWID() AS varbinary(3)) AS int) % 900) + 100 AS [Sum]
,(CAST(CAST(NEWID() AS varbinary(3)) AS int) % 2) + 1 AS TypeID
,(CAST(CAST(NEWID() AS varbinary(3)) AS int) % 10) + 1 AS PlaceID
,(CAST(CAST(NEWID() AS varbinary(3)) AS int) % 3) + 1 AS StatisID
FROM t16M
WHERE num <= 10000;
命令:
install
对于文件夹,$ install -m 644 /test/path/ myfile.php
mkdir
参数:
-m
您可能必须将其作为$ mkdir -m 755 test
执行。
答案 2 :(得分:0)
您可以使用以下命令创建目录并同时授予权限
mkdir -m755 test