mkdir创建目录或文件夹
- 命令功能:mkdir (make directory) 创建目录或文件夹,创建的用户在当前目录中需要具有写权限。使用mkdir命令创建指定的目录或文件夹名,要求并且指定的目录名不能是当前目录中已有的目录。同一个目录下不能有同名的(区分大小写)。
- 命令格式:
[[email protected] ~]#mkdir 【选项】目录名称
- 命令参数:
- 命令实例:
实例1:创建一个空目录
[[email protected] test]#mkdir test1 [[email protected] test]# ls -l total 4 drwxr-xr-x. 2 root root 4096Nov 1 14:09 test1 [[email protected] test]#
实例2:创建多层目录
[[email protected] test]# mkdir -p test2/test22 [[email protected] test]# ls -l total 8 drwxr-xr-x. 2 root root 4096Nov 1 14:09 test1 drwxr-xr-x. 3 root root 4096Nov 1 14:15 test2 [[email protected] test]# cd test2/ [[email protected] test2]# ls -l total 4 drwxr-xr-x. 2 root root 4096Nov 1 14:15 test22 [[email protected] test2]#
实例3:创建权限为777的目录
[[email protected] test]# mkdir -m 777 test3 [[email protected] test]# ls -l total 12 drwxr-xr-x. 2 root root 4096Nov 1 14:09 test1 drwxr-xr-x. 3 root root 4096Nov 1 14:15 test2 drwxrwxrwx. 2 root root 4096Nov 1 14:18 test3 [[email protected] test]#
说明:test3的权限为rwxrwxrwx
实例4:创建新目录都显示信息
[[email protected] test]# mkdir -v test4 mkdir: created directory `test4‘ [[email protected] test]# mkdir -vp test5/test5-1 mkdir: created directory `test5‘ mkdir: created directory`test5/test5-1‘ [[email protected] test]#
实例5:一个命令创建项目的目录结构
[[email protected] test]# mkdir -vp abc/{a/,b/,c/{e,f},123/{1,2},ser/dep/{h,k}} mkdir: created directory `abc‘ mkdir: created directory `abc/a/‘ mkdir: created directory `abc/b/‘ mkdir: created directory `abc/c‘ mkdir: created directory `abc/c/e‘ mkdir: created directory `abc/c/f‘ mkdir: created directory `abc/123‘ mkdir: created directory`abc/123/1‘ mkdir: created directory`abc/123/2‘ mkdir: created directory `abc/ser‘ mkdir: created directory`abc/ser/dep‘ mkdir: created directory`abc/ser/dep/h‘ mkdir: created directory`abc/ser/dep/k‘ [[email protected] test]# tree abc/ abc/ ├── 123 │ ├── 1 │ └── 2 ├── a ├── b ├── c │ ├── e │ └── f └── ser └── dep ├── h └── k 12 directories, 0 files [[email protected]]#
时间: 2024-11-19 04:48:00