最常用的Linux命令總結
阿新 • • 發佈:2019-01-04
本部落格是一些最常用的Linux命令,對命令的解釋不深入,僅僅是日常使用,有些日常的小技巧,也即是當做筆記希望對大家有用:
- pwd命令
- cd命令
- ls命令
- cp命令
- mv命令
- more命令
- tail命令
- tar命令
- ifconfig命令
pwd命令
pwd命令是顯示當前目錄
輸出
[[email protected] ~]$ pwd
/home/darren
[[email protected] ~]$
cd 命令
cd命令是切換目錄命令使用
cd 空格 進入當前使用者主目錄
[ [email protected] ~]$ cd
[[email protected] ~]$ pwd
/home/darren
[[email protected] ~]$
cd ~ 進入當前使用者主目錄
[[email protected] ~]$ cd ~
[[email protected] ~]$ pwd
/home/darren
cd / 進入根目錄
[[email protected] /]$ pwd
/
[[email protected] /]$
cd /home/darren/test 進入絕對目錄的路徑
[[email protected] /]$ cd /home/darren/test
[[email protected] test]$ pwd
/home/darren/test
cd - 是進入上次進入的目錄
ls命令
ls命令是顯示目錄列表
常用ls
[[email protected] test]$ ls
happy HellWord.java
[[email protected] test]$
ls -l 顯示詳細資訊和 ll命令等同
[[email protected] test]$ ll -l
總計 8
drwxrwxr-x 2 darren darren 4096 10-23 15:00 happy
-rw-rw-r-- 1 darren darren 33 10-23 15:02 HellWord.java
[ [email protected] test]$
ls -a 顯示所有的包括隱藏檔案
[[email protected]localhost test]$ ls -a
. .. happy HellWord.java
[[email protected] test]$
ls -ltr
-r:以檔名反序排列並輸出目錄內容列表;
-t:用檔案和目錄的更改時間排序;
展示檔案列表按照時間和檔名字元排序
[[email protected] test]$ ll -ltr
總計 8
drwxrwxr-x 2 darren darren 4096 10-23 15:00 happy
-rw-rw-r-- 1 darren darren 33 10-23 15:02 HellWord.java
[[email protected] test]$
CP命令
cp是拷貝命令經常用於備份檔案
cp 檔名 新路徑
cp HellWord.java /home/darren
實現了向/home/darren目錄下拷貝檔案
cp -r 資料夾 新路徑 資料夾拷貝
cp -p 檔名 新路徑 保留屬性拷貝
cp 檔名 新檔名 可以實現拷貝以後重新命名
MV命令
mv命令是移動命令
mv 檔名 新檔名 實現重新命名
mv 檔名 新路徑 到新目錄檔案中
more命令
檢視檔案內容命令經常檢視日誌和文字文件
more 檔名 即可檢視檔案內容
tail命令
tail 命令也是查詢檔案內容
經常用到
tail -f 檔名 可以實現實時監控檔案
tailf 檔名 同樣可以實現該功能
tail -100f 檔名 首先載入100行
tail -100 檔名 檢視文件最後面的100行
tail -n 100 檔名 檢視文件最後面的100行
搞不太懂去除-n和不去除有什麼區別
tar命令
tar命令是壓縮命令
常用命令
tar -cvf 壓縮的名字.tar 被壓縮的檔案 實現將檔案壓縮為一個tar包
tar -xvf 壓縮的名字.tar 實現tar包的解壓
tar -czf 壓縮的名字.tar.gz 被壓縮的檔案 實現壓縮文件
ifconfig命令
Linux中檢視本機IP則使用ifconfig
此僅僅是作為筆記使用,並不完善,後續會完善。
參考http://man.linuxde.net/編寫