mkdir創建目錄
mkdir 目錄名
可以在當前目錄下創建一個新目錄。如果你想要在其他目錄下創建目錄輸入絕對路徑就行了
[root@VM_22_43_centos test]# mkdir abc
[root@VM_22_43_centos test]# ls
abc
[root@VM_22_43_centos test]# mkdir /tmp/abc
[root@VM_22_43_centos test]# ls /tmp
abc
注意每次只能創建一層目錄,如果想一下子創建多級目錄的話需要使用-p
選項
[root@VM_22_43_centos test]# mkdir /tmp/test/test2
mkdir: 無法創建目錄"/tmp/test/test2": 沒有那個文件或目錄
[root@VM_22_43_centos test]# mkdir -p /tmp/test/test2
[root@VM_22_43_centos test]# ls /tmp/test/
test2
touch創建空文件
touch 文件名
可以在當前目錄下創建一個空文件,touch 絕對路徑/文件名
可以在任意位置下創建空文件
[root@VM_22_43_centos test]# touch abc.log
[root@VM_22_43_centos test]# ls
abc.log test2
注意:linux中打開文件方式不以後綴區分,也就是說你寫.zip與.txt,linux系統不會覺得有區別,但爲了人易於維護,一般見名知意,文件寫通用的後綴
touch命令並不常用,因爲vi/vim文件修改命令可以直接創建文件