1. 程式人生 > >Linux的一些常用命令(一)

Linux的一些常用命令(一)

linux 快捷鍵
1、ls 列出本地址上檔案,
  -a 列出所有(包括隱藏檔案)
  -l 按照列表方式顯示
  -t 按照時間方式排序

2、touch 建立檔案


3、  echo 'abc' > 檔名 寫入檔案內容(覆蓋之前的內容)
  echo 'cdc' >> 檔名 在檔案後面新增資訊

4、mkdir -p test/test1/test2 建立目錄

5、cat 檔名 : 可以檢視檔案內容

6、 head - (n) 2 檔名 : 可以檢視檔案的前兩行
  tail -(n) 3 檔名 : 可以檢視檔案後幾行 (其中n是可以省略的,負號不可以省略)

7、tree : 可以檢視檔案數結構

8、cd :回根目錄
  cd ~ : 回根目錄
  cd - : 返回剛才的目錄
  cd .. :返回上一級目錄
  cd . : 當前目錄

9、find . -name '*.txt' : 檢視當前目錄下的所有以 .txt結尾的檔案 (name是固定的不用改變)

10、sudo find / -name '*.txt' :使用高許可權在根目錄下尋找 ,所有以 .txt 為結尾的檔案

11、pwd :檢視當前所在目錄

12、cp :複製命令
  cp test1.txt new.txt
  原來檔案 新檔案
  cp test1.txt /home/tarena/1910xly/xinwenjainming.txt
  路徑加上 新檔名

13、mv 原檔案 新檔案 : 剪下
  mv new.txt new2.txt

14、rm -f :強制刪除
  -r :把子目錄刪除
  -i:詢問是否刪除