Linux基礎cd、pwd和ls命令
阿新 • • 發佈:2019-01-01
cd命令
cd命令是change directory的縮寫,中文翻譯:更改資料夾(目錄)。
cd destination
cd命令可接受單個引數destination,用以指定想切換到的目錄名。如果沒有為cd命令指定目標路徑,它將切換到使用者主目錄。
- 單點符".",表示當前目錄;
- 雙點符"..",表示當前目錄的父目錄。
pwd命令
pwd命令是print working directory的縮寫,中文翻譯:列印工作目錄.
ls命令
ls命令是list files的縮寫,中文翻譯:顯示當前目錄下的檔案和目錄。
ls命令輸出的列表是按字母排序的(按照列排序而不是行)。
# "-F"選項,會在目錄名後面加上“/”,“-d”選項只列出目錄本身的資訊,不列出其中的內容 -> ls -F Applications/ Desktop/ Documents/ Downloads/ Library/ Movies/ Music/ Pictures/ Public/ maven/ tomcat/ # "-a"選項會把隱藏檔案和普通檔案一起顯示出來 -> ls -a . .android .gitconfig .oracle_jre_usage .tooling .. .bash_history .idea .p2 .viminfo # "-R"選項是遞迴選項,它會列出當前目錄下包含的子目錄中的檔案。 -> ls -F -R ......
ls命令查詢的用法
# "-l"選項會產生長列表格式的輸出,包含了目錄中每個檔案的更多相關資訊
-> ls -l
total 0
drwx------ 4 yangyun staff 128 3 16 2018 Applications
......
drwxr-xr-x 5 yangyun staff 160 10 27 11:22 tomcat
ls命令過濾輸出列表
-> ls -l linux total 4 drwxrwxr-x 5 git git 4096 Nov 3 08:17 find # “?”代表一個字元 # “*”代表零個或多個字元 -> ls -l l?x ls: cannot access 'l?n': No such file or directory -> ls -l lin?x total 4 drwxrwxr-x 5 git git 4096 Nov 3 08:17 find -> ls -l l*x total 4 drwxrwxr-x 5 git git 4096 Nov 3 08:17 find -> ls -l lin*x total 4 drwxrwxr-x 5 git git 4096 Nov 3 08:17 find # 也可以只用中括號,裡面的字元之間的關係是或關係 -> ls -l lin[ui]x total 4 drwxrwxr-x 5 git git 4096 Nov 3 08:17 find # "-"表示兩個字母之間的範圍 -> ls -l lin[a-z]x total 4 drwxrwxr-x 5 git git 4096 Nov 3 08:17 find # "!"表示將不需要的內容排除在外 -> ls -l lin[!a]x total 4 drwxrwxr-x 5 git git 4096 Nov 3 08:17 find