1.獲取命令幫助
Linux中的命令按可分類shell內(nèi)嵌命令谈宛、外部命令昂芜,獲取命令幫助信息前需要區(qū)分命令類型哄辣。
1.1 type - 查看命令類型
[root@VM_0_171_centos ~]# type echo
echo 是 shell 內(nèi)嵌
[root@VM_0_171_centos ~]# type pwd
pwd 是 shell 內(nèi)嵌
[root@VM_0_171_centos ~]# type cd
cd 是 shell 內(nèi)嵌
[root@VM_0_171_centos ~]# type ls
ls 是 `ls --color=auto' 的別名
[root@VM_0_171_centos ~]# type man
man 是 /usr/bin/man
[root@VM_0_171_centos ~]# type whatis
whatis 是 /usr/bin/whatis
[root@VM_0_171_centos ~]# type whereis
whereis 是 /usr/bin/whereis
[root@VM_0_171_centos ~]#
1.2 help 內(nèi)嵌命令 - 查看shell內(nèi)嵌命令幫助
[root@VM_0_171_centos ~]# help echo
echo: echo [-neE] [參數(shù) ...]
將參數(shù)寫到標準輸出吐根。
在標準輸出上顯示 ARG 參數(shù)后跟一個換行正歼。
選項:
-n 不要追加換行
-e 啟用下列反斜杠轉義的解釋
-E 顯式地抑制對于反斜杠轉義的解釋
`echo' 對下列反斜杠字符進行轉義:
\a 警告(響鈴)
\b 退格
\c 抑制更多的輸出
\e 轉義字符
\f 格式提供
\n 換行
\r 回車
\t 橫向制表符
\v 縱向制表符
\\ 反斜杠
\0nnn 以 NNN (八進制)為 ASCII 碼的字符。 NNN 可以是
0到3個八進制數(shù)字
\xHH 以 HH (十六進制)為值的八比特字符拷橘。HH可以是
一個或兩個十六進制數(shù)字
退出狀態(tài):
返回成功除非有寫錯誤發(fā)生局义。
[root@VM_0_171_centos ~]#
1.3 whatis - 顯示手冊頁描述
通常用于輔助man命令,確定幫助手冊章節(jié)
[root@VM_0_171_centos ~]# whatis whatis
whatis (1) - display manual page descriptions
[root@VM_0_171_centos ~]#
1.4 man [章節(jié)] 外部命令 - 查看外部命令幫助
man命令用來查看外部程序的幫助膜楷,有時需要配合whatis使用旭咽,因為man命令的幫助文檔會按章節(jié)劃分,各章節(jié)分別存放不同內(nèi)容的幫助信息
幫助信息章節(jié)劃分
1.用戶命令
2.系統(tǒng)調(diào)用
3.C庫調(diào)用
4.設備文件及特殊文件
5.文件格式(配置文件格式)
6.游戲使用幫助
7.雜項
8.管理工具及守護進程
[root@VM_0_171_centos ~]# man man
MAN(1) Manual pager utils MAN(1)
NAME
man - an interface to the on-line reference manuals
SYNOPSIS
man [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L
locale] [-m system[,...]] [-M path] [-S list] [-e extension] [-i|-I]
[--regex|--wildcard] [--names-only] [-a] [-u] [--no-subpages] [-P
pager] [-r prompt] [-7] [-E encoding] [--no-hyphenation] [--no-justifi‐
cation] [-p string] [-t] [-T[device]] [-H[browser]] [-X[dpi]] [-Z]
[[section] page ...] ...
man -k [apropos options] regexp ...
man -K [-w|-W] [-S list] [-i|-I] [--regex] [section] term ...
man -f [whatis options] page ...
man -l [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L
locale] [-P pager] [-r prompt] [-7] [-E encoding] [-p string] [-t]
[-T[device]] [-H[browser]] [-X[dpi]] [-Z] file ...
man -w|-W [-C file] [-d] [-D] page ...
man -c [-C file] [-d] [-D] page ...
man [-?V]
DESCRIPTION
man is the system's manual pager. Each page argument given to man is
Manual page man(1) line 1 (press h for help or q to quit)
手冊頁常用操作
j | Enter : 向下翻一行
k : 向上翻一行
d : 向下翻半屏
u : 向上翻半屏
Space : 向下翻一屏
b : 向上翻一屏
G : 跳轉至最后一行
nG : 跳轉至第n行
/關鍵字 : 從上向下查找關鍵字(n:定位到下一個 赌厅,N:定位到上一個)
?關鍵字 : 從下向上查找關鍵字
2.顯示一行文本 echo
SYNOPSIS
echo [SHORT-OPTION]... [STRING]...
echo LONG-OPTION
OPTIONS
-n do not output the trailing newline(不輸出尾隨行)
-e enable interpretation of backslash escapes(啟用轉義)
-E disable interpretation of backslash escapes (default) (禁用轉義)
--help 顯示幫助
--version 顯示版本信息
EXAMPLES
[root@VM_0_171_centos ~]# echo "hello world"
hello world
[root@VM_0_171_centos ~]# echo $SHELL
/bin/bash
[root@VM_0_171_centos ~]# echo -e "hello\tworld\nlinux"
hello world
linux
[root@VM_0_171_centos ~]#
3.日期時間相關
3.1 date - print or set the system date and time 打印或設置系統(tǒng)日期和時間
SYNOPSIS
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
OPTIONS
-R, --rfc-2822 output date and time in RFC 2822 format. Example: Mon, 07 Aug 2006 12:34:56 -0600
-s, --set=STRING set time described by STRING (用字符串設置時間穷绵,而非使用MMDDhhmm[[CC]YY][.ss])
EXAMPLES
date命令顯示日期、時間
[root@VM_0_171_centos ~]# date
2017年 04月 03日 星期一 17:32:35 CST
[root@VM_0_171_centos ~]# date -R
Mon, 03 Apr 2017 17:32:41 +0800
[root@VM_0_171_centos ~]# date "+%Y-%m-%d %H:%M:%S.%N"
2017-04-03 17:33:21.620667704
[root@VM_0_171_centos ~]# date +%s
1491212010
[root@VM_0_171_centos ~]# date +%X
17時33分38秒
[root@VM_0_171_centos ~]# date +%x
2017年04月03日
[root@VM_0_171_centos ~]#
date命令設置日期特愿、時間
[root@VM_0_171_centos ~]# date -s "2016-04-03 17:36:30"
2016年 04月 03日 星期日 17:36:30 CST
[root@VM_0_171_centos ~]# date 040317382017.20
2017年 04月 03日 星期一 17:38:20 CST
[root@VM_0_171_centos ~]#
3.2 hwclock,clock - query or set the hardware clock (RTC) 查詢或設置硬件時鐘
SYNOPSIS
hwclock [function] [option...]
FUNCTIONS
-s, --hctosys 以硬件為準仲墨,把系統(tǒng)調(diào)整為與硬件時間相同
-w, --systohc 以系統(tǒng)為準,把硬件時間調(diào)整為與系統(tǒng)時鐘相同
3.3 cal - display a calendar 顯示日歷
SYNOPSIS
cal [options] [[[day] month] year]
OPTIONS
-1, --one Display single month output. (This is the default.)
-3, --three Display prev/current/next month output.
-s, --sunday Display Sunday as the first day of the week.
-m, --monday Display Monday as the first day of the week.
-j, --julian Display Julian dates (days one-based, numbered from January 1).
-y, --year Display a calendar for the current year.
EXAMPLES
[root@VM_0_171_centos ~]# cal
四月 2017
日 一 二 三 四 五 六
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
[root@VM_0_171_centos ~]# cal -m
四月 2017
一 二 三 四 五 六 日
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
[root@VM_0_171_centos ~]# cal -3
三月 2017 四月 2017 五月 2017
日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六
1 2 3 4 1 1 2 3 4 5 6
5 6 7 8 9 10 11 2 3 4 5 6 7 8 7 8 9 10 11 12 13
12 13 14 15 16 17 18 9 10 11 12 13 14 15 14 15 16 17 18 19 20
19 20 21 22 23 24 25 16 17 18 19 20 21 22 21 22 23 24 25 26 27
26 27 28 29 30 31 23 24 25 26 27 28 29 28 29 30 31
30
[root@VM_0_171_centos ~]# cal -y
2017
一月 二月 三月
日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六
1 2 3 4 5 6 7 1 2 3 4 1 2 3 4
8 9 10 11 12 13 14 5 6 7 8 9 10 11 5 6 7 8 9 10 11
15 16 17 18 19 20 21 12 13 14 15 16 17 18 12 13 14 15 16 17 18
22 23 24 25 26 27 28 19 20 21 22 23 24 25 19 20 21 22 23 24 25
29 30 31 26 27 28 26 27 28 29 30 31
四月 五月 六月
日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六
1 1 2 3 4 5 6 1 2 3
2 3 4 5 6 7 8 7 8 9 10 11 12 13 4 5 6 7 8 9 10
9 10 11 12 13 14 15 14 15 16 17 18 19 20 11 12 13 14 15 16 17
16 17 18 19 20 21 22 21 22 23 24 25 26 27 18 19 20 21 22 23 24
23 24 25 26 27 28 29 28 29 30 31 25 26 27 28 29 30
30
七月 八月 九月
日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六
1 1 2 3 4 5 1 2
2 3 4 5 6 7 8 6 7 8 9 10 11 12 3 4 5 6 7 8 9
9 10 11 12 13 14 15 13 14 15 16 17 18 19 10 11 12 13 14 15 16
16 17 18 19 20 21 22 20 21 22 23 24 25 26 17 18 19 20 21 22 23
23 24 25 26 27 28 29 27 28 29 30 31 24 25 26 27 28 29 30
30 31
十月 十一月 十二月
日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六
1 2 3 4 5 6 7 1 2 3 4 1 2
8 9 10 11 12 13 14 5 6 7 8 9 10 11 3 4 5 6 7 8 9
15 16 17 18 19 20 21 12 13 14 15 16 17 18 10 11 12 13 14 15 16
22 23 24 25 26 27 28 19 20 21 22 23 24 25 17 18 19 20 21 22 23
29 30 31 26 27 28 29 30 24 25 26 27 28 29 30
31
[root@VM_0_171_centos ~]#
3.停止揍障、關機目养、重啟
遠程操作一般而言禁止關機,只能重啟毒嫡,否則無法開機(本地機房或者云服務器除外癌蚁,但對服務器操作而言,重啟而非關機是一個好的習慣)
3.1 halt, poweroff, reboot - Halt, power-off or reboot the machine
SYNOPSIS
halt [OPTIONS...]
poweroff [OPTIONS...]
reboot [OPTIONS...]
OPTIONS
--halt
Halt the machine, regardless of which one of the three commands is invoked.
-p, --poweroff
Power-off the machine, regardless of which one of the three commands is invoked.
--reboot
Reboot the machine, regardless of which one of the three commands is invoked.
-f, --force
Force immediate halt, power-off, reboot. Do not contact the init system.
-w, --wtmp-only
Only write wtmp shutdown entry, do not actually halt, power-off,reboot.
-d, --no-wtmp
Do not write wtmp shutdown entry.
--no-wall
Do not send wall message before halt, power-off, reboot.
halt兜畸、poweroff努释、reboot這3個命令比較簡單,而且可以被shutdown替代
3.2 shutdown - Halt, power-off or reboot the machine
SYNOPSIS
shutdown [OPTIONS...] [TIME] [WALL...]
OPTIONS
-H, --halt
Halt the machine.
-P, --poweroff
Power-off the machine (the default).
-r, --reboot
Reboot the machine.
-h
Equivalent to --poweroff, unless --halt is specified.
-k
Do not halt, power-off, reboot, just write wall message.
--no-wall
Do not send wall message before halt, power-off, reboot.
-c
Cancel a pending shutdown. This may be used cancel the effect of an invocation of shutdown with a time argument that is not "+0" or "now".
EXAMPLES
shutdown這個命令不難咬摇,執(zhí)行結果比較特殊伐蒂,就不做演示了。