mkdir's “-p” option

后端 未结 5 1818
南方客
南方客 2021-01-30 00:26

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.

5条回答
  •  迷失自我
    2021-01-30 01:14

    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
    

    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 created both, hello and goodbye

    This means that the command will create all the directories necessaries to fulfill your request, not returning any error in case that directory exists.

    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. 
    

    Hence rlidwka means: All permissions on.

    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.

提交回复
热议问题