当前位置: 首页 > Linux

每天学一个Linux命令(16):mkdir

时间:2023-04-06 05:52:08 Linux

昨天:每天学一个Linux命令(15):man命令介绍mkdir命令用于新建目录。创建目录时,如果目录名前没有指定路径,则直接在当前工作目录下创建一个新目录。如果指定路径,将在指定目录下创建一个新目录。创建目录时需要注意。您创建的目录名称与当前目录中的文件名称不同。如果存在重名,系统会出现如下提示,无法创建成功。[root@centos7test]#ls-ltotal0-rw-r--r--1rootroot0Jan207:06test[root@centos7test]#mkdirtestmkdir:cannotcreatedirectory'test':Fileexists命令语法mkdir[option][directoryname]mkdir[option][directory]??optiondescription-m,--mode=mode#setpermissions(类似于chmod)-p,--parents#可以是路径名,递归创建目录,可以创建目录路径中不存在的目录,即可以一次创建多个目录;-v,--verbose#显示创建目录的创建过程信息--help#显示帮助信息并退出--version#输出版本新建一个目录(一个目录)[root@centos7~]#mkdirtestdir[root@centos7~]#ls-ltotal21884-rw------。1rootroot1320Aug2010:39anaconda-ks.cfgdrwxr-xr-x2rootroot6Jan207:12testdir一次创建多个目录[root@centos7~]#cdtestdir[root@centos7testdir]#ls[root@centos7testdir]#mkdirtest1test2test3test4[root@centos7testdir]#lstest1test2test3test4[root@centos7testdir]#mkdir-ptest6/{1..5}[root@centos7testdir]#treetest6test6├──1├──2...st5/test':Nosuchfileordirectory[root@centos7testdir]#mkdir-ptest5/test[root@centos7testdir]#tree.├──test1├──test2├──test3├──test4└──test5└──test6目录,0个文件创建目录时,配置其权限#新建目录,默认权限为755[root@centos7test5]#lltotal0drwxr-xr-x2rootroot6Jan207:16test[root@centos7test5]#mkdir-m777test1[root@centos7test5]#lltotal0drwxr-xr-x2rootroot6Jan207:16testdrwxrwxrwx2rootroot6Jan207:38test1mkidr命令在每日使用过程基本就是创建一个目录,没有其他常见的用途。因此,该命令掌握起来比较简单,易学易用。每天学一个Linux命令(十四):cat每天学一个Linux命令(十三):touch每天学一个Linux命令(十二):chown