Linux常用命令(四) - mkdir

來源:互聯網
上載者:User

標籤:style   blog   color   ar   os   sp   strong   檔案   on   

linux mkdir 命令用來建立指定的名稱的目錄,要求建立目錄的使用者在目前的目錄中具有寫入權限,並且指定的目錄名不能是目前的目錄中已有的目錄。

1. 命令格式:

mkdir  [選項]   目錄


2. 命令功能:

通過 mkdir 命令可以實現在指定位置建立以指定的檔案名稱命名的檔案夾。要建立檔案夾的使用者必須對所建立的檔案夾的父資料夾具有寫入權限。並且,所建立的檔案夾不能與其父資料夾中的檔案名稱重名,即同一個檔案夾下不能有同名的(區分大小寫)。 


3. 命令參數:

-m,    --mode 模式,設定許可權<模式> (類似 chmod)

-p,    --parents  可以是一個路徑名稱。此時若路徑中的某些目錄尚不存在,加上此選項後,系統將自動建立好那些尚不存在的目錄,即一次可以建立多個目錄; 

-v,    --verbose  每次建立新目錄都顯示資訊


4. 命令執行個體:

執行個體1:建立一個空目錄

命令: mkdir test1


執行個體2:遞迴建立多個目錄

命令: mkdir -p test2/test22


執行個體3:建立許可權為777的目錄:

命令: mkdir -m 777 test3

輸出: 

[[email protected] test]# mkdir -m 777 test3[[email protected] test]# lldrwxr-xr-x 2 root root 4096 10-25 17:42 test1drwxr-xr-x 3 root root 4096 10-25 17:44 test2drwxrwxrwx 2 root root 4096 10-25 17:46 test3[[email protected] test]#
說明: test3的許可權為rwxrwxrwx

執行個體4:建立新目錄都顯示資訊

命令: mkdir -v test4

輸出:

[[email protected] test]# mkdir -v test4mkdir: 已建立目錄 “test4”

執行個體5:一個命令建立項目的目錄結構

命令:mkdir -vp scf/{lib/,bin/,doc/{info,product},logs/{info,product},service/deploy/{info,product}} 

[[email protected] test]# mkdir -vp scf/{lib/,bin/,doc/{info,product},logs/{info,product},service/deploy/{info,product}}mkdir: 已建立目錄 “scf”mkdir: 已建立目錄 “scf/lib”mkdir: 已建立目錄 “scf/bin”mkdir: 已建立目錄 “scf/doc”mkdir: 已建立目錄 “scf/doc/info”mkdir: 已建立目錄 “scf/doc/product”mkdir: 已建立目錄 “scf/logs”mkdir: 已建立目錄 “scf/logs/info”mkdir: 已建立目錄 “scf/logs/product”mkdir: 已建立目錄 “scf/service”mkdir: 已建立目錄 “scf/service/deploy”mkdir: 已建立目錄 “scf/service/deploy/info”mkdir: 已建立目錄 “scf/service/deploy/product”[[email protected] test]# tree scf/scf/|-- bin|-- doc|   |-- info|   |-- product|-- lib|-- logs|   |-- info|   |-- product|-- service    |-- deploy      |-- info        |-- product12 directories, 0 files[[email protected] test]#

Linux常用命令(四) - mkdir

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.