问题描述
所以这似乎不是我遇到的一个非常复杂的问题,但这是我找不到答案的问题.我对 -p
选项在Unix中的功能感到困惑.在创建子目录然后在该目录中创建另一个子目录时,我将其用于实验室分配.看起来像这样:
So this doesn't seem like a terribly complicated question I have, but it's one I can't find the answer to. I'm confused about what the -p
option does in Unix. I used it for a lab assignment while creating a subdirectory and then another subdirectory within that one. It looked like this:
mkdir -p cmps012m/lab1
该文件位于具有正常权限( rlidwka
)的私有目录中.哦,有人会介意解释 rlidwka
的含义吗?我并不是Unix的初学者,但是我对它的含义不是很熟悉.希望这不是一个太模糊的问题.
This is in a private directory with normal rights (rlidwka
). Oh, and would someone mind giving a little explanation of what rlidwka
means? I'm not a total noob to Unix, but I'm not really familiar with what this means. Hopefully that's not too vague of a question.
推荐答案
手册页是您可以找到的最佳信息来源...并且唾手可得: man mkdir
给出了以下内容: -p
开关:
The man pages is the best source of information you can find... and is at your fingertips: man mkdir
yields this about -p
switch:
-p, --parents
no error if existing, make parent directories as needed
用例示例:假设我要创建目录 hello/goodbye
,但不存在:
Use case example: Assume I want to create directories hello/goodbye
but none exist:
$mkdir hello/goodbye
mkdir:cannot create directory 'hello/goodbye': No such file or directory
$mkdir -p hello/goodbye
$
-p
创建了 hello
和再见
这意味着该命令将创建满足您的请求所需的所有目录,如果该目录存在,则不会返回任何错误.
关于 rlidwka
,Google对于首字母缩写词:)有很好的记忆力.我的搜索返回了以下示例: http://www.cs.cmu.edu/~help/afs/afs_acls.html
About rlidwka
, Google has a very good memory for acronyms :). My search returned this for example: 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
的意思是:对的所有权限.
Hence rlidwka
means: All permissions on.
值得一提的是,正如@KeithThompson在评论中指出的那样,并不是所有的Unix系统都支持ACL.因此, rlidwka
概念可能不适用于此处.
It's worth mentioning, as @KeithThompson pointed out in the comments, that not all Unix systems support ACL. So probably the rlidwka
concept doesn't apply here.
这篇关于mkdir的"-p"选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!