linux常用基本命令整理
1 -cd 切換目錄
cd 進入用戶主目錄;
cd ~ 進入用戶主目錄;
cd - 返回進入此目錄之前所在的目錄;
cd .. 返回上級目錄(若當前目錄爲“/“,則執行完後還在“/";".."爲上級目錄的意 思);
cd ../.. 返回上兩級目錄;
cd !$ 把上個命令的參數作爲cd參數使用。
2 -pwd 顯示目前所在的工作目錄
3 -ls 查看當前目錄
在Linux文件系統中,所有以點(.)開始的文件名都是隱藏文件(區分ls -a與ls -A)
-d:不顯示目錄內容,而只顯示該目錄名
-l --long:以長格式顯示文件的詳細屬性
4 -mkdir 創建目錄
5 -rmdir 刪除空目錄(只能刪除空目錄)
6 -rm 刪除目錄 文件
7 -touch 創建空文件(注意與mkdir的區別)
8 -stat 顯示指定文件的詳細信息,比ls更詳細
-c(較爲重要)
9 -nano
用法: nano [選項] [[+行,列] 文件名]...
^託字符 表示ctrl鍵
保存文檔 的內容
10 cat -E -n -b ctrl+d退出
用法:cat [選項]...[文件]...
-b, --number-nonblank 對非空輸出行編號
-s, --squeeze-blank 不輸出多行空行,合併空白行爲一行
-E, --show-ends 在每行結束處顯示"$"
-n,--number 對輸出的所有行編號
11 tac cat的逆序輸出
用法:tac [選項]...[文件]..
12 head 默認顯示前十行
用法:head [選項]... [文件]...
-c, --bytes=[-]K printthe first K bytes of each file;
withthe leading '-', print all but the last
Kbytes of each file
-n, --lines=[-]K print the first K lines instead of thefirst 10;
with the leading'-', print all but the last
13 tail 監控小文件的變化情況
用法:tail [選項]... [文件]...
Print the last 10 lines of each FILE to standard output.
With more than one FILE, precede each with a header giving the filename.
-f, --follow[={name|descriptor}]
output appended data as the file grows; an absent option argument means'descriptor' 使用ctrl+c 退出
14 more less(分頁顯示)
日期時間
硬件時鐘 hwclock clock
-s
-k
--set --date
系統時鐘 date(內核模擬)
SYNOPSIS
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMD‐
Dhhmm[[CC]YY][.ss]] 例如:date"031211092017"
[root@localhost 桌面]# date -s"2017/11/11 11:11:11"
[root@localhost 桌面]# date -s"2017-11-11 11:11:11"
%F 完整日期格式,等價於 %Y-%m-%d
%D 按月計的日期;等於%m/%d/%y
%s 自UTC 時間 1970-01-01 00:00:00 以來所經過的秒數 [root@localhost 桌面]# date +%s
15 cal -y
關機
16 Halt
17 Shutdown
SYNOPSIS
shutdown [OPTIONS...] [TIME] [WALL...] 絕對時間和相對時間
-k Do not halt, power-off, reboot, justwrite wall
message.
-c Cancel a pending shutdown. This may be usedcancel
the effect of an invocation ofshutdown with a
time argument that is not"+0" or "now"
註銷(與windows有差別)
18 exit :
19 logout
20 ctrl+d
拷貝
21 cp
用法:cp [選項]... 源文件 目標文件(單元複製 可改名)
或:cp [選項]... 源文件... 目錄(多元複製)
或:cp [選項]... -t 目錄 源文件...(一般不用)
Copy SOURCE to DEST, or multiple SOURCE(s) toDIRECTORY.
選項 [root@localhost 桌面]# echo $?
-d:
-p:在複製文件時能夠保留文件的屬性和所有
-r/R:
-a:相當於選項的組合
22 mv
用法:mv [選項]... [-T] 源文件 目標文件
或:mv [選項]... 源文件... 目錄
或:mv [選項]... -t 目錄 源文件...
Rename SOURCE to DEST, or move SOURCE(s) toDIRECTORY.