歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux 之創建工作目錄-mkdir

Linux 之創建工作目錄-mkdir

日期:2017/2/28 13:47:44   编辑:Linux教程

在Linux下創建工作目錄,一般使用 “mkdir" 指令,以下將介紹“mkdir”指令的使用方法,供大家參考。

一、使用幫助

在Linux終端(命令行)輸入:mkdir --help,輸出如下信息:

Usage: mkdir [OPTION]... DIRECTORY...
Create the DIRECTORY(ies), if they do not already exist.

Mandatory arguments to long options are mandatory for short options too.
-m, --mode=MODE set file mode (as in chmod), not a=rwx - umask
-p, --parents no error if existing, make parent directories as needed
-v, --verbose print a message for each created directory
-Z set SELinux security context of each created directory
to the default type
--context[=CTX] like -Z, or if CTX is specified then set the SELinux
or SMACK security context to CTX
--help display this help and exit
--version output version information and exit

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'mkdir invocation'

二、mkdir 各參數說明

語法:mkdir [OPTION]... DIRECTORY...

條件:要創建的目錄DIRECTORY不存在,否則將會報錯

參數:

  -m  設定創建目錄的權限,其權限模式同 "chmod",r=4, w=2, x=1;

  -p  遞歸創建目錄,如果子目錄的父目錄已存在,也不會報錯;若子目錄存在,也不會報錯,且不會覆蓋已存在的子目錄中的數據文件;

  -v  逐個顯示要創建的目錄的信息,描述每一個新創建的目錄;

  -Z  設置目錄的 SELinux 安全上下文信息;

    --help  提供幫助信息;

    --version  描述版本號。

實例:

1  mkdir -m 0775 test01

2  mkdir -p /home/bin/test02

3  mkdir -v test03

4  mkdir -m 0555 -p -v /home/lbin/test/test01/test02 

    mkdir: created directory ‘/home/liupf/test/test01’
    mkdir: created directory ‘/home/liupf/test/test01/test02’

Copyright © Linux教程網 All Rights Reserved