1. 程式人生 > 實用技巧 >001_Linux常用命令之ls命令

001_Linux常用命令之ls命令

1. 認識Linux系統目錄結構
/bin					可執行檔案所在目錄
/media 掛載裝置媒體,u盤,光碟機等
/mnt 該目錄主要是為了讓使用者掛在別的檔案系統(掛在自己的u盤)
/usr unix system resources,龐大和複雜的目錄,很多應用會安裝到此目錄(/usr/local-使用者自己安裝軟體的目錄)
/sbin 超級管理員root的可執行檔案目錄
/proc 此目錄是系統記憶體的對映,會保留程式執行的一些資訊
/etc 系統軟體的啟動和配置目錄
/dev 裝置檔案所在目錄
/home/user 使用者家目錄
2.ls命令常規用法
  • ls(list)檢視檔案資訊
  • ls -l顯示詳細資訊
[email protected]:/usr# ls -l
總用量 128
drwxr-xr-x 2 root root 69632 8月 4 2016 bin
drwxr-xr-x 2 root root 4096 4月 21 2016 games
drwxr-xr-x 75 root root 4096 8月 4 2016 include
drwxr-xr-x 145 root root 4096 8月 4 2016 lib
drwxr-xr-x 3 root root 4096 8月 4 2016 lib32
drwxr-xr-x 3 root root 4096 8月 4 2016 libx32
drwxr-xr-x 11 root root 4096 8月 4 2016 local
drwxr-xr-x 3 root root 4096 4月 21 2016 locale
drwxr-xr-x 2 root root 12288 8月 4 2016 sbin
drwxr-xr-x 320 root root 12288 8月 4 2016 share
drwxr-xr-x 8 root root 4096 7月 30 2016 src
  • ls -a顯示隱藏的檔案或目錄
[email protected]:/usr# ls -a
. .. bin games include lib lib32 libx32 local locale sbin share src
  • ls -R遞迴顯示子目錄的內容
[email protected]:/usr# ls -R
  • ls -lrt按照時間順序
[email protected]:/usr# ls -lrt
總用量 128
drwxr-xr-x 2 root root 4096 4月 21 2016 games
drwxr-xr-x 3 root root 4096 4月 21 2016 locale
drwxr-xr-x 8 root root 4096 7月 30 2016 src
drwxr-xr-x 11 root root 4096 8月 4 2016 local
drwxr-xr-x 320 root root 12288 8月 4 2016 share
drwxr-xr-x 3 root root 4096 8月 4 2016 lib32
drwxr-xr-x 3 root root 4096 8月 4 2016 libx32
drwxr-xr-x 75 root root 4096 8月 4 2016 include
drwxr-xr-x 145 root root 4096 8月 4 2016 lib
drwxr-xr-x 2 root root 12288 8月 4 2016 sbin
drwxr-xr-x 2 root root 69632 8月 4 2016 bin
  • ls .c(註釋:代表任意多個字元)
  • ls func.?(註釋:?代表任意一個字元)
3.認識路徑

以“/”開頭的路徑為絕對路徑,也就是無論你在哪裡,只要輸入絕對路徑,我們都可以到達

那麼不是"/"開頭的路徑為相對路徑