linux, linux系統(tǒng)下的mkdir命令是什么?下面是mkdir命令的具體介紹:
1.mkdir命令簡介:
mkdir命令可用于在指定位置創(chuàng)建名為DirName(指定文件名)的文件夾或目錄。想要創(chuàng)建文件夾或目錄的用戶必須對所創(chuàng)建文件夾的父文件夾具有寫權(quán)限。而且,
創(chuàng)建的文件夾(目錄)不能與其父目錄(即父文件夾)中的文件名同名,即同一目錄中不能有同名文件(區(qū)分大小寫)。
2、mkdir命令功能:
mkdir命令用于創(chuàng)建目錄。
3.語法:
Mkdir(選項)(參數(shù))
4.命令參數(shù);
-m指定創(chuàng)建目錄的權(quán)限。
-p創(chuàng)建級聯(lián)目錄,并創(chuàng)建現(xiàn)有目錄而不報告錯誤。
Rmdir刪除目錄(不能刪除文件)。當跟隨多個目錄時,這些目錄由空格分隔。
-p刪除級聯(lián)目錄
Rm -r刪除一個目錄,可以刪除一個非空目錄。
-f強制刪除
通常用法:rm -rf /usr/local/***
切記不要使用rm -rf/,這樣會刪除系統(tǒng)下和程序員禁區(qū)內(nèi)的所有文件。
Chmod -R 777文件夾名稱為文件夾和其中的文件添加權(quán)限。
Execute the script command: /filename.sh or bash filename.sh.
終端設置行號:set number
修改文件名字: mv hello.h world.h 將hello.h 重命名為world.h
移動文件: mv hello.cpp /usr/dest/將hello.cpp移動到/usr/dest 目錄下
舉例:
創(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]#
遞歸創(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
[root@localhost test2]#
創(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
[root@localhost test]#
說明:
test3 的權(quán)限為rwxrwxrwx
創(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”
[root@localhost test]#
一個命令創(chuàng)建項目的目錄結(jié)構(gòu):
命令:
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
12directories,0files
[root@localhosttest]#
linux,以上就是本文為您收集整理的linux最新內(nèi)容,希望能幫到您!更多相關(guān)內(nèi)容歡迎關(guān)注。