gpt4 book ai didi

unix - mkdir 的 "-p"选项

转载 作者:行者123 更新时间:2023-12-03 05:05:31 24 4
gpt4 key购买 nike

所以这似乎不是一个非常复杂的问题,但我找不到答案。我对 -p 选项在 Unix 中的作用感到困惑。我将它用于实验室作业,同时创建一个子目录,然后在该子目录中创建另一个子目录。它看起来像这样:

mkdir -p cmps012m/lab1

它位于具有普通权限的私有(private)目录中 (rlidwka)。哦,有人介意稍微解释一下 rlidwka 的含义吗?我并不是 Unix 的菜鸟,但我不太熟悉这意味着什么。希望这不是一个太含糊的问题。

最佳答案

手册页是您可以找到的最佳信息来源...并且触手可及:man mkdir 产生关于 -p 开关的信息:

-p, --parents
no error if existing, make parent directories as needed

用例示例:假设我想创建目录 hello/goodbye 但不存在:

$mkdir hello/goodbye
mkdir:cannot create directory 'hello/goodbye': No such file or directory
$mkdir -p hello/goodbye
$

-p 创建了 hellogoodbye

这意味着该命令将创建满足您的请求所需的所有目录,如果该目录存在,则不会返回任何错误

关于 rlidwka,Google 对于首字母缩略词有很好的内存力:)。我的搜索返回了这个,例如:http://www.cs.cmu.edu/~help/afs/afs_acls.html

 Directory permissions

l (lookup)
Allows one to list the contents of a directory. It does not allow the reading of files.
i (insert)
Allows one to create new files in a directory or copy new files to a directory.
d (delete)
Allows one to remove files and sub-directories from a directory.
a (administer)
Allows one to change a directory's ACL. The owner of a directory can always change the ACL of a directory that s/he owns, along with the ACLs of any subdirectories in that directory.

File permissions

r (read)
Allows one to read the contents of file in the directory.
w (write)
Allows one to modify the contents of files in a directory and use chmod on them.
k (lock)
Allows programs to lock files in a directory.

因此 rlidwka 的意思是:所有权限

值得一提的是,正如 @KeithThompson 在评论中指出的那样,并非所有 Unix 系统都支持 ACL。因此,rlidwka 概念可能不适用于此处。

关于unix - mkdir 的 "-p"选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22737933/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com