mkdir の "-p" オプション 質問する

mkdir の

これはそれほど複雑な質問ではないようですが、答えが見つかりません。Unix-pでこのオプションが何をするのかよくわかりません。ラボの課題でサブディレクトリを作成し、その中に別のサブディレクトリを作成するときにこれを使用しました。次のようになりました。

mkdir -p cmps012m/lab1

これは、通常の権限 ( ) を持つプライベート ディレクトリにありますrlidwka。 ああ、これが何を意味するのか、少し説明していただけますかrlidwka? 私は Unix の初心者ではありませんが、これが何を意味するのかよくわかりません。 あまり漠然とした質問ではないことを願っています。

ベストアンサー1

man ページは、見つけられる最高の情報源です...そして、すぐに利用できます:スイッチ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概念はここでは適用されません。

おすすめ記事