pwd : Printing working directory
cd changing directory
cd ~ :return to home directory
cd ~username :return to user's home
cd - : 當前目錄和前面目錄切換
cd ..
ls 列出指定目錄下的內容
ls -a : 顯示所有文件包括隱藏文件
ls -A: 顯示除 . 和 .. 之外的所有文件
more file
less file
head file: 顯示文件前幾行的內容
head -n 行數 file
tail file: 顯示文件後幾行的內容
tail -n 行數 -f file : -f 表示顯示內容並且不退出文件 , 可以ctrl + c 手動退出。
tail -n 20 -f /tmp/functions
stat file : 顯示文件或文件系統的狀態
touch filename : change timestamp of the file
cp: copy
單源複製:
cp source dest
如果dest 不存在,則先創建文件,並負責內容。
如果dest存在;1) dest 是非目錄文件,則覆蓋文件
2). dest 是目錄文件 則創建一個文件,並複製到文件中。
多源複製:
cp source ... directory
cp -t directory source...
如果dest不存在,則錯誤
如果dest存在,但不是目錄,則錯誤
如果dest存在,是目錄,則複製並保留相同文件名。
copy -i 覆蓋之前提醒確認
copy -f 強制覆蓋目標文件
copy -r 遞歸複製目錄 recursive 如果目標目錄不存在,則創建空目錄並複製內容。如果目標存在,就把源目錄和內容複製過去。
copy -d 複製源文件而不是快捷方式
copy -a 保留原來所有的屬性 = copy -p all
mv source dest
mv -i/-f 同copy
mv hello hello.txt 同一個目錄下,重命名
mv functions /x 不同目錄下,移動
rm 移除 很難恢復,最好自建備份,而不要直接刪除。
rm file
rm -i
rm -r directory : 遞歸刪除目錄
rm -rf 強制遞歸刪除
rm -rf /path/to/directory
mkdir dir
-p : 自動按需創建父目錄
-v: 顯示詳細過程
-m Mode : 直接給定權限
rmdir dir: 目錄裏必須是空
cat主要有三大功能:
1.一次顯示整個文件。$ cat filename
2.從鍵盤創建一個文件。$ cat > filename
只能創建新文件,不能編輯已有文件.
3.將幾個文件合併爲一個文件: $cat file1 file2 > file
參數:
-n 或 --number 由 1 開始對所有輸出的行數編號
-b 或 --number-nonblank 和 -n 相似,只不過對於空白行不編號
-s 或 --squeeze-blank 當遇到有連續兩行以上的空白行,就代換爲一行的空白行
-v 或 --show-nonprinting