日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux mkdir绝对路径,linux学习(六)绝对路径、相对路径、cd、mkdir、rmdir、rm(示例代码)...

發布時間:2023/12/15 linux 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux mkdir绝对路径,linux学习(六)绝对路径、相对路径、cd、mkdir、rmdir、rm(示例代码)... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、絕對路徑

就是從根開始的,如:/root、/usr/local。

二、相對路徑

相對于當前路徑的,比如我們在當前路徑下建立了一個a.txt。

[[email?protected] ~]# pwd/]# ls1.cap 33.txt Application iptables.bak oneinstack shellscripts1.ipt a.php Document.pdf npm-debug.log ruanwenwu syncwithgit.sh

[[email?protected]~]# ls1.cap 33.txt Application Document.pdf npm-debug.log ruanwenwu syncwithgit.sh1.ipt a.php a.txt iptables.bak oneinstack shellscripts

[[email?protected]~]#

三、cd命令

cd命令的意思是change directory,即更換目錄。

[[email?protected] ~]# pwd/ruanwenwu

[[email?protected] ruanwenwu]#

cd命令的幾個常用參數:

切換到上一級目錄:

]# pwd/

切換到家目錄

切換到上一個目錄(類似于遙控器換臺)

四、mkdir

mkdir命令用來創建目錄。

創建一個目錄:

[[email?protected] ~]# mkdir 1

[[email?protected] ~]# ls

1 1.ipt a.php a.txt iptables.bak oneinstack shellscripts

1.cap 33.txt Application Document.pdf npm-debug.log ruanwenwu syncwithgit.sh

創建某時給默認的權限

[[email?protected] ~]# mkdir -m 777 2lt

total1920drwxrwxrwx2 root root 4096 Oct 24 00:05 2drwxr-xr-x 2 root root 4096 Oct 24 00:04 1

-rw-r--r-- 1 root root 0 Oct 23 23:58a.txt

drwxr-xr-x 5 root root 4096 Sep 11 12:59Application

drwxr-xr-x 3 root root 4096 Apr 24 20:11shellscripts-rwxr-xr-x 1 root root 599 Apr 10 2017syncwithgit.sh-rw-r--r-- 1 root root 8242 Mar 26 2017 npm-debug.log-rw-r--r-- 1 root root 0 Mar 26 2017 33.txt-rw-r--r-- 1 root root 36 Mar 10 2017a.php-rw-r--r-- 1 root root 296 Mar 1 2017iptables.bak-rw-r--r-- 1 root root 0 Mar 1 2017 1.ipt-rw-r--r-- 1 tcpdump tcpdump 24 Mar 1 2017 1.cap

drwxrwxrwx2 root root 4096 Nov 5 2016ruanwenwu

drwxr-xr-x 7 root root 4096 Feb 21 2016oneinstack-rw-r--r-- 1 root root 1909424 Feb 21 2016 Document.pdf

可以看到,給了默認權限的2目錄和1目錄的權限是不一樣的。默認的1的權限是755。

連續創建目錄:

[[email?protected] ~]# mkdir 3/4/5mkdir: cannot create directory ‘3/4/5’: No such file or directory

[[email?protected]~]# mkdir -p 3/4/5]# ls1 1.ipt 3a.php a.txt iptables.bak oneinstack shellscripts1.cap 2 33.txt Application Document.pdf npm-debug.log ruanwenwu syncwithgit.sh

[[email?protected]~]# tree 3

-bash: tree: command not found

[[email?protected]~]# yum install tree

[[email?protected]~]# tree 3

3└──4└──5

可以看到,不加p參數,是不可以連續創建的。

五、rmdir

rmdir的用途是刪掉目錄。他的功能比較雞肋,它只能刪除空的目錄。

刪除空的目錄5:

在4下創建文件,然后再試圖去刪掉4:

[[email?protected] ~]# touch 3/4/3/4rmdir: failed to remove ‘3/4’: Directory not empty

rmdir有個p參數,可以連續刪除多個目錄,和mkdir的p參數對應,但是也只能刪除空目錄:

[[email?protected] ~]# rmdir -p 3/4rmdir: failed to remove ‘3/4’: Directory not empty

刪除4目錄下的aa.txt,然后再試一次:

[[email?protected] ~]# rm 3/4/aa.txt

rm: remove regular empty file ‘3/4/aa.txt’?3/43

3[error opening dir]0 directories, 0 files

六、rm命令

rm命令用來刪除文件和目錄。

在上面的例子里我們已經看到,rm不加任何參數時,系統會給出提示。如果加f參數就不會了:

[[email?protected] ~]# mkdir 33/3/a.txt

rm: remove regular empty file ‘3/a.txt’?3/a.txt

那么rm刪除目錄是怎樣的呢?

[[email?protected] ~]# touch 3/3rm: cannot remove ‘3’: Is a directory

看來,rm不能直接刪除目錄,但是加上r參數后就可以了:

[[email?protected] ~]# rm 3rm: cannot remove ‘3’: Is a directory

[[email?protected]~]# rm -rf 33ls: cannot access3: No such file or directory

總結

以上是生活随笔為你收集整理的linux mkdir绝对路径,linux学习(六)绝对路径、相对路径、cd、mkdir、rmdir、rm(示例代码)...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。