一個簡單的linux命令 mkdir
mkdir 命令用于創(chuàng)建指定名稱的目錄,要求用戶具有要創(chuàng)建的目錄下的讀寫權(quán)限。
一、命令格式
mkdir [option] Dir…
二、命令參數(shù)
-m, --mode=模式,設(shè)定權(quán)限<模式> (類似 chmod),而不是 rwxrwxrwx 減 umask
-p, --parents 可以是一個路徑名稱。此時若路徑中的某些目錄尚不存在,加上此選項后,系統(tǒng)將自動建立好那些尚不存在的目錄,即一次可以建立多個目錄;
-v, --verbose 每次創(chuàng)建新目錄都顯示信息
--help 顯示此幫助信息并退出
--version 輸出版本信息并退出
三、命令實例
1.創(chuàng)建目錄
命令:mkdir test1
輸出:
[root@localhost soft]# cd test [root@localhost test]# mkdir test1 [root@localhost test]# ll 總計 4drwxr-xr-x 2 root root 4096 10-25 17:42 test1 [root@localhost test]#
2.遞歸創(chuàng)建多個目錄
命令:mkdir -p test2/test22
輸出:
[root@localhost test]# mkdir -p test2/test22 [root@localhost test]# ll 總計 8drwxr-xr-x 2 root root 4096 10-25 17:42 test1 drwxr-xr-x 3 root root 4096 10-25 17:44 test2 [root@localhost test]# cd test2/ [root@localhost test2]# ll 總計 4drwxr-xr-x 2 root root 4096 10-25 17:44 test22
3.創(chuàng)建權(quán)限為777的目錄
命令:mkdir -m 777 test3
輸出:
[root@localhost test]# mkdir -m 777 test3 [root@localhost test]# ll 總計 12drwxr-xr-x 2 root root 4096 10-25 17:42 test1 drwxr-xr-x 3 root root 4096 10-25 17:44 test2 drwxrwxrwx 2 root root 4096 10-25 17:46 test3
4.創(chuàng)建新目錄都顯示信息
命令:mkdir -v test4
輸出:
[root@localhost test]# mkdir -v test4 mkdir: 已創(chuàng)建目錄 “test4” [root@localhost test]# mkdir -vp test5/test5-1 mkdir: 已創(chuàng)建目錄 “test5” mkdir: 已創(chuàng)建目錄 “test5/test5-1”
5.一個命令創(chuàng)建項目的目錄結(jié)構(gòu)
參考:http://www.ibm.com/developerworks/cn/aix/library/au-badunixhabits.html
命令:
mkdir -vp scf/{lib/,bin/,doc/{info,product},logs/{info,product},service/deploy/{info,product}}
輸出:
[root@localhost test]# mkdir -vp scf/{lib/,bin/,doc/{info,product},logs/{info,product},service/deploy/{info,product}} mkdir: 已創(chuàng)建目錄 “scf” mkdir: 已創(chuàng)建目錄 “scf/lib” mkdir: 已創(chuàng)建目錄 “scf/bin” mkdir: 已創(chuàng)建目錄 “scf/doc” mkdir: 已創(chuàng)建目錄 “scf/doc/info” mkdir: 已創(chuàng)建目錄 “scf/doc/product” mkdir: 已創(chuàng)建目錄 “scf/logs” mkdir: 已創(chuàng)建目錄 “scf/logs/info” mkdir: 已創(chuàng)建目錄 “scf/logs/product” mkdir: 已創(chuàng)建目錄 “scf/service” mkdir: 已創(chuàng)建目錄 “scf/service/deploy” mkdir: 已創(chuàng)建目錄 “scf/service/deploy/info” mkdir: 已創(chuàng)建目錄 “scf/service/deploy/product” [root@localhost test]# tree scf/ scf/ |-- bin |-- doc | |-- info | `-- product |-- lib |-- logs | |-- info | `-- product `-- service `-- deploy |-- info `-- product 12 directories, 0 files
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Shell腳本實現(xiàn)線上服務(wù)器之間對比文件是否一致
這篇文章主要介紹了Shell腳本實現(xiàn)線上服務(wù)器之間對比文件是否一致,本文腳本在特殊環(huán)境下使用,需要的朋友可以參考下2014-12-12Linux makefile 和shell文件相互調(diào)用實例詳解
這篇文章主要介紹了Linux makefile 和shell文件相互調(diào)用實例詳解的相關(guān)資料,需要的朋友可以參考下2017-03-03shell腳本編程之循環(huán)語句學(xué)習(xí)筆記
這篇文章主要介紹了shell腳本編程之循環(huán)語句學(xué)習(xí)筆記,本文內(nèi)容較簡單,可以作為shell循環(huán)語句的備忘錄,忘記怎么寫時來看看吧~需要的朋友可以參考下2014-09-09Shell編程之/bin/bash和/bin/sh的區(qū)別淺析
在redhat的系統(tǒng)中,sh是一個到bash的軟鏈接,但是如果運行如下程序會產(chǎn)生不一樣的結(jié)果,下面這篇文章主要給大家介紹了關(guān)于Shell編程之/bin/bash和/bin/sh的區(qū)別的相關(guān)資料,需要的朋友可以參考下2022-07-07