• Linux命令之mkdir


    mkdir [选项] 目录

    若指定目录不存在则创建目录

    (1).常用选项

    -m,--mode=模式  设置权限模式(类似chmod),而不是rwxrwxrwx减umask
    -p,--parents  需要时创建目标目录的上层目录,但即使这些目录已存在也不当作错误处理
    -v,--verbose  每次创建新目录都显示信息
    -Z,--context=CTX  将每个创建的目录的SELinux安全环境设置为CTX
    --version  显示版本信息并退出

    (2).实例

    当前目录下创建一个新文件夹

    [ root@CentOS6 桌面]# ll
    总用量  0
    [ root@CentOS6 桌面]# mkdir mainDir
    [ root@CentOS6 桌面]# ll
    总用量  4
    drwxr-xr-x.  2  root  root  4096  4月    8  09:49  mainDir
    

     在当前目录下创建一个新的文件夹,并输出信息

    [ root@CentOS6 桌面]# mkdir –v secondDir
    Mkdir:已创建目录“secondDir”
    [ root@CentOS6 桌面]# ll
    总用量  8
    drwxr-xr-x.  2  root  root  4096  4月    8  09:49  mainDir
    drwxr-xr-x.  2  root  root  4096  4月    8  10:02  secondDir

    在指定目录下创建文件夹,该文件夹只有创建者自己有读写执行权限

    [ root@CentOS6 桌面]# mkdir –m 700 thirdDir/test7
    [ root@CentOS6 桌面]# cdthirdDir/
    [ root@CentOS6 桌面]# ll
    总用量  28
    drwxr-xr-x.  2  root  root  4096  4月    8  10:15  test1
    drwxr-xr-x.  2  root  root  4096  4月    8  10:15  test2
    drwxr-xr-x.  2  root  root  4096  4月    8  10:15  test3
    drwxr-xr-x.  2  root  root  4096  4月    8  10:47  test4
    drwxr-xr-x.  2  root  root  4096  4月    8  10:47  test5
    drwxr-xr-x.  2  root  root  4096  4月    8  10:47  test6
    drwx------.  2  root  root  4096  4月    8  12:31  test7
    

    在当前目录下创建一个新的文件夹,且包含多个子文件夹,另外-p选项支持多层级目录

    [ root@CentOS6 桌面]# mkdir –p thirdDir/{test1,test2,test3}
    [ root@CentOS6 桌面]# ll
    总用量  12
    drwxr-xr-x.  2  root  root  4096  4月    8  09:49  mainDir
    drwxr-xr-x.  2  root  root  4096  4月    8  10:02  secondDir
    drwxr-xr-x.  5  root  root  4096  4月    8  10:15  thirdDir
    [ root@CentOS6 桌面]# cd thirdDir
    [ root@CentOS6 thirdDir]# ll
    总用量  12
    drwxr-xr-x.  2  root  root  4096  4月    8  10:15  test1
    drwxr-xr-x.  2  root  root  4096  4月    8  10:15  test2
    drwxr-xr-x.  2  root  root  4096  4月    8  10:15  test3
    [ root@CentOS6 thirdDir]# cd ..
    [ root@CentOS6 桌面]# mkdir thirdDir/{test4,test5,test6}
    [ root@CentOS6 桌面]# ll
    总用量  12
    drwxr-xr-x.  2  root  root  4096  4月    8  09:49  mainDir
    drwxr-xr-x.  2  root  root  4096  4月    8  10:02  secondDir
    drwxr-xr-x.  5  root  root  4096  4月    8  10:15  thirdDir
    [ root@CentOS6 桌面]# cd thirdDir
    [ root@CentOS6 thirdDir]# ll
    总用量  12
    drwxr-xr-x.  2  root  root  4096  4月    8  10:15  test1
    drwxr-xr-x.  2  root  root  4096  4月    8  10:15  test2
    drwxr-xr-x.  2  root  root  4096  4月    8  10:15  test3
    drwxr-xr-x.  2  root  root  4096  4月    8  10:47  test4
    drwxr-xr-x.  2  root  root  4096  4月    8  10:47  test5
    drwxr-xr-x.  2  root  root  4096  4月    8  10:47  test6

    在当前目录下创建指定文件夹,该文件夹只有创建者自己有读写执行权限,同组用户可读和执行权限

    [ root@CentOS6 桌面]# mkdir -pm 750 bin/os_1
    [ root@CentOS6 桌面]# ll
    总用量  16
    drwxr-xr-x.  3  root  root  4096  4月  8  12:54  bin
    drwxr-xr-x.  2  root  root  4096  4月  8  09:49  bin
    drwxr-xr-x.  2  root  root  4096  4月  8  10:02  bin
    drwxr-xr-x.  9  root  root  4096  4月  8  12:31  bin
    [ root@CentOS6 桌面]# cd bin
    [ root@CentOS6 bin]# ll
    总用量  4
    drwxr-x---.  2  root  root  4096  4月    8  12:54  os_1
  • 相关阅读:
    【批处理】for命令
    【批处理】if命令,注释方式
    【批处理】choice命令,call 命令,start 命令,rem
    LoadLibrary加载动态库失败
    编译器如何实现静态变量只初始化一次
    汇编语言中 cs, ds,ss 的区别
    变量在内存中的位置
    call和ret指令
    函数调用
    浮动
  • 原文地址:https://www.cnblogs.com/diantong/p/8742953.html
Copyright © 2020-2023  润新知