zl程序教程

您现在的位置是:首页 >  系统

当前栏目

Linux命令之mkdir详解程序员

Linux命令程序员 详解 mkdir
2023-06-13 09:20:05 时间
-m,--mode=模式 设置权限模式(类似chmod),而不是rwxrwxrwx减umask 

-p,--parents 需要时创建目标目录的上层目录,但即使这些目录已存在也不当作错误处理 

-v,--verbose 每次创建新目录都显示信息 

-Z,--context=CTX 将每个创建的目录的SELinux安全环境设置为CTX 

--version 显示版本信息并退出

(2).实例

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

[ [email protected] 桌面]# ll 

总用量 0 

[ [email protected] 桌面]# mkdir mainDir 

[ [email protected] 桌面]# ll 

总用量 4 

drwxr-xr-x. 2 root root 4096 4月 8 09:49 mainDir 

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

[ [email protected] 桌面]# mkdir –v secondDir 

Mkdir:已创建目录“secondDir” 

[ [email protected] 桌面]# 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

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

[ [email protected] 桌面]# mkdir –m 700 thirdDir/test7 

[ [email protected] 桌面]# cdthirdDir/ 

[ [email protected] 桌面]# 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选项支持多层级目录

[ [email protected] 桌面]# mkdir –p thirdDir/{test1,test2,test3} 

[ [email protected] 桌面]# 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 

[ [email protected] 桌面]# cd thirdDir 

[ [email protected] 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 

[ [email protected] thirdDir]# cd .. 

[ [email protected] 桌面]# mkdir thirdDir/{test4,test5,test6} 

[ [email protected] 桌面]# 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 

[ [email protected] 桌面]# cd thirdDir 

[ [email protected] 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

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

[ [email protected] 桌面]# mkdir -pm 750 bin/os_1 

[ [email protected] 桌面]# 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 

[ [email protected] 桌面]# cd bin 

[ [email protected] bin]# ll 

总用量 4 

drwxr-x---. 2 root root 4096 4月 8 12:54 os_1

2852.html

服务器部署程序员系统优化网站设置运维