Linux-幫助與基本命令

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í)行結果比較特殊伐蒂,就不做演示了。

最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末肛鹏,一起剝皮案震驚了整個濱河市逸邦,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌在扰,老刑警劉巖缕减,帶你破解...
    沈念sama閱讀 218,204評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異健田,居然都是意外死亡烛卧,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,091評論 3 395
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來总放,“玉大人呈宇,你說我怎么就攤上這事【中郏” “怎么了甥啄?”我有些...
    開封第一講書人閱讀 164,548評論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長炬搭。 經(jīng)常有香客問我蜈漓,道長,這世上最難降的妖魔是什么宫盔? 我笑而不...
    開封第一講書人閱讀 58,657評論 1 293
  • 正文 為了忘掉前任融虽,我火速辦了婚禮,結果婚禮上灼芭,老公的妹妹穿的比我還像新娘有额。我一直安慰自己,他們只是感情好彼绷,可當我...
    茶點故事閱讀 67,689評論 6 392
  • 文/花漫 我一把揭開白布巍佑。 她就那樣靜靜地躺著,像睡著了一般寄悯。 火紅的嫁衣襯著肌膚如雪萤衰。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,554評論 1 305
  • 那天猜旬,我揣著相機與錄音脆栋,去河邊找鬼。 笑死洒擦,一個胖子當著我的面吹牛筹吐,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播秘遏,決...
    沈念sama閱讀 40,302評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼嘉竟!你這毒婦竟也來了邦危?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 39,216評論 0 276
  • 序言:老撾萬榮一對情侶失蹤舍扰,失蹤者是張志新(化名)和其女友劉穎倦蚪,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體边苹,經(jīng)...
    沈念sama閱讀 45,661評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡陵且,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,851評論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片慕购。...
    茶點故事閱讀 39,977評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡聊疲,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出沪悲,到底是詐尸還是另有隱情获洲,我是刑警寧澤,帶...
    沈念sama閱讀 35,697評論 5 347
  • 正文 年R本政府宣布殿如,位于F島的核電站贡珊,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏涉馁。R本人自食惡果不足惜门岔,卻給世界環(huán)境...
    茶點故事閱讀 41,306評論 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望烤送。 院中可真熱鬧寒随,春花似錦、人聲如沸胯努。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,898評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽叶沛。三九已至蒲讯,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間灰署,已是汗流浹背判帮。 一陣腳步聲響...
    開封第一講書人閱讀 33,019評論 1 270
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留溉箕,地道東北人晦墙。 一個月前我還...
    沈念sama閱讀 48,138評論 3 370
  • 正文 我出身青樓,卻偏偏與公主長得像肴茄,于是被迫代替她去往敵國和親晌畅。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 44,927評論 2 355

推薦閱讀更多精彩內(nèi)容