linux基本命令

1.linux命令

    命令    參數      目標

ls          -s                test

ls             --size        test

注意:1.參數用來指定命令的默寫功能,可以加也可以不加
2.命令和參數目標之間要用空格隔開
3.參數中”-”表示單詞的縮寫,“--”表示單詞的全拼
4.在執行命令時遵循的這些規則,特殊情況除外
5.命令必須在提示符之後輸入,沒有提示符的輸入是無效的

       6.使用參數時 -a -b -c=-abc=-bac=-cab

2.文件建立
key 1: touch filename(創建多個文件 touch file{1..10})
touch:(修改文件的時間戳)
功能:
1.用於把已存在文件時間標籤更新爲系統當前時間(默認方式),他們的數據將原封不動的保留下來
2.創建新的空文件
linux基本命令
命令參數:

-a change only the access time
-c, --no-create do not create any files
-d, --date=STRING parse STRING and use it instead of current time
-f (ignored)
-h, --no-dereference affect each symbolic link instead of any referenced
file (useful only on systems that can change the
timestamps of a symlink)
-m change only the modification time
-r, --reference=FILE use this file's times instead of current time
-t STAMP use [[CC]YY]MMDDhhmm[.ss] instead of current time
--time=WORD change the specified time:
WORD is access, atime, or use: equivalent to -a
WORD is modify or mtime: equivalent to -m
--help display this help and exit
--version output version information and exit

常用三個參數: atime:文件內容被訪問的時間標示
mtime:文件內容被修改的時間
ctime:文件屬性或者文件內容被修改的時間的表示
注:用stat 文件名可以查看文件的狀態(有三個轉態access modefy(對文件的內容進行修改) change(可以對文件的內容和權限進行修改))
用命令gnome -t 時間 文件名 可以對文件的時間進行修改

touch常用命令(在時間上):

touch -t 時間(年月日時分) 文件名

touch -r 目標文件 源文件

key 2: gedit(只能在圖形界面)gedit file ##必須有圖形

key3:vim(在圖形界面和文本界面都可以)vim file -->按[i]進入insert模式-->書寫內容-->按[esc]退出insert模式-->:wq退出保存

批註:vim異常退出:(vim異常退出時會出現.file.swp文件)

   file name: ~kiosk/Desktop/hello
      modified: YES
     user name: kiosk   host name: foundation0.ilt.example.com
    process ID: 31820
If this already, delete the swap file ".hello.swp" <<<此文件中存放大是未保存的數據

Swap file ".hello.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
只讀打開 繼續編輯 恢復數據 刪除swap文件 退出 退出

注:無論按[O] (E) (R) (Q) (A) 任何一個都不會刪除.swp文件
那麼再次打開hello文件是還會出現以上界面直到按(D),.swp文件被刪除

解決辦法:1.重新進入,輸入R

       2.esc  -->:wq退出文件

       3 在此進入 D刪除 q退出,在此進入
                 (備註:如果不行可以利用ls -a命令查看所有文件,刪除未保存文件的.swp隱藏文件即可)

3目錄建立
1.mkdir directory
2.mkdir -p dir1/dir2/dir3 (-p建立遞歸目錄時,當上層目錄不存在自動建立,必須通過-p進行操作)
linux基本命令
4文件、目錄刪除
1.文件:rm file
rm -f file -f表示--force(表示強制刪除)
2.目錄:rm -r directory -r 表示遞歸刪除(類似於-p),也就是刪除目錄本身和裏面內容
rm -r -f dir 刪除目錄不提示 == rm -rf dir ==rm -fr dir
linux基本命令
5文件複製(注意文件到文件 還是目錄到目錄的使用 注意Mv命令時如果換了磁盤會發生Id位置的變化)

cp
源文件 目的地文件

cp -r
源文目錄 目的地目錄
cp
源文件1 源文件2 目的地目錄
cp -r
源目錄1 源目錄2
目的地目錄

6文件移動

mv 源文件 目的地文件
mv 源目錄
目的地目錄
mv dir/* .

注:相同磁盤的文件移動只是一個重明名過程
不同磁盤的文件移動是複製刪除過程

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章