Linux基礎入門html
做者:尹正傑java
版權聲明:原創做品,謝絕轉載!不然將追究法律責任。node
一.用戶登陸python
root 用戶
一個特殊的管理賬戶
也被稱爲超級用戶
root已接近完整的系統控制
對系統損害幾乎有無限的能力
除非必要,不要登陸爲root
普通( 非特權 )用戶
權限有限
形成損害的能力比較有限
二.終端terminal mysql
設備終端
主要指物理設備,能夠看得見摸得着的,如:鍵盤、鼠標、顯示器。
物理終端( /dev/console )
控制檯console,好比去機房接入的KVM中,咱們在顯示器上看到的窗口就是物理終端。
串行終端( /dev/ttyS# )
ttyS,主要指用線纜鏈接的終端,好比咱們使用思科,H3C交換機須要使用Console線進行鏈接,經過Console接口插入,在經過轉換器轉換成USB接口,插入電腦後,使用相應的軟件進行鏈接輸入相應的設備命令來本地管理設備的方式,如今基本上都爲設備配置了IP地址,工做中咱們基本上遠程操做接口,除非你第一次去機房上線這臺設備會用到。
虛擬終端(tty:teletypewriters, /dev/tty#
tty 可有n個,Ctrl+Alt+F#
圖形終端( /dev/tty7 ) startx, xwindows
CentOS 6: Ctrl + Alt + F7
CentOS 7: 在哪一個終端啓動,即位於哪一個虛擬終端
僞終端( pty:pseudo-tty , /dev/pts/# )
pty, SSH遠程鏈接
查看當前的終端設備:
tty
三.交互式接口linux
交互式接口:
啓動終端後,在終端設備附加一個交互式應用程序
GUI:Graphic User Interface(圖形化運行環境,通常適合初學者學習)
X protocol, window manager, desktop
Desktop:
GNOME (C, 圖形庫gtk),
KDE (C++,圖形庫qt)
XFCE (輕量級桌面)
CLI:Command Line Interface(字符運行環境,生產環境通常用這種)
shell程序
四.Shell解釋器ios
1>.什麼是shellnginx
Shell是Linux系統的用戶界面,提供了用戶與內核進行交互操做的一種接口。 它接收用戶輸入的命令並把它送入內核去執行
shell也被稱爲LINUX的命令解釋器(command interpreter)
shell是一種高級程序設計語言
2>.各類shellgit
一.Linux有不少shell種類,常見的有: sh (Steve Bourne ) csh tcsh ksh (korn) bash (bourn again shell)GPL zsh ...... 二.Base Shell相關
1>.GNU Bourne-Again Shell(bash)是GNU計劃中重要的工具軟件之一,目前也是 Linux標準的shell,與sh兼容,CentOS默認使用Bash。
2>.顯示當前使用的shell [root@node101.yinzhengjie.org.cn ~]# echo ${SHELL} /bin/bash [root@node101.yinzhengjie.org.cn ~]# 3>.顯示當前系統使用的全部shell [root@node101.yinzhengjie.org.cn ~]# cat /etc/shells /bin/sh /bin/bash /usr/bin/sh /usr/bin/bash /bin/tcsh /bin/csh [root@node101.yinzhengjie.org.cn ~]# 4>.主機名示例: [root@node101.yinzhengjie.org.cn ~]# cat /etc/hostname bj-jiuxianqiao-k8s-node101.yinzhengjie.org.cn [root@node101.yinzhengjie.org.cn ~]#
3>.命令提示符 redis
1.設置ps1變量的顯示 PS1(是數字1而不是字母l),每一個版本bash的PS1變量內的特殊符號可能有些小的差別,你能夠先man bash 一下。下面是FC4環境下默認的特殊符號所表明的意義: \d :表明日期,格式爲weekday month date,例如:"Mon Aug 1" \H :完整的主機名稱。例如:個人機器名稱爲:fc4.linux,則這個名稱就是fc4.linux \h :僅取主機的第一個名字,如上例,則爲fc4,.linux則被省略 \t :顯示時間爲24小時格式,如:HH:MM:SS \T :顯示時間爲12小時格式 \A :顯示時間爲24小時格式:HH:MM \u :當前用戶的帳號名稱 \v :BASH的版本信息 \w :完整的工做目錄名稱。家目錄會以 ~代替 \W :利用basename取得工做目錄名稱,因此只會列出最後一個目錄 \# :下達的第幾個命令 \$ :提示字符,若是是root時,提示符爲:# ,普通用戶則爲:$ 默認的PS1內容爲: PS1='[\u@\h \W]\$ ' ,因此默認的提示符就是: [root@linux ~]#。
設置ps1變量的顏色 咱們可以經過配置PS1變量使提示符成爲彩色。在PS1中配置字符序列顏色的格式爲: \[\e[F;Bm\] 基本上是夾在 "\e["(轉義開方括號)和 "m" 之間數字值。假如指定一個以上的數字代碼,則用分號將他們分開。 其中 F 爲字體顏色,編號30~37; B 爲背景色,編號40~47。 可經過 \e[0m 關閉顏色輸出;特別的,當B爲1時,將顯示加亮加粗的文字,請看下面的顏色表和代碼表。 顏色表 前景 背景 顏色 --------------------------------------- 黑色 紅色 綠色 黃色 藍色 紫色 青色 白色
命令提示符:prompt [root@node101.yinzhengjie.org.cn ~]# # 管理員 $ 普通用戶 顯示提示符格式 [root@node101.yinzhengjie.org.cn ~]# echo $PS1 [\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$ #我推薦使用這種方式 [root@node101.yinzhengjie.org.cn ~]# 修改提示符格式 PS1="\[\e[1;5;41;33m\][\u@\h \W]\\$\[\e[0m\]" #帶有閃爍效果的命令行提示 PS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" #帶有時間的命令行提示 修改提示符格式並永久寫入配置文件
咱們可用經過修改"/etc/bashrc"文件中的PS1變量,也能夠在"/etc/profile.d/"目錄下建立一個"*.sh"的文件名稱,將PS1的變量寫入便可。 [23:57:28 root@node101.yinzhengjie.org.cn ~]#cat /etc/profile.d/env.sh #文件名稱咱們自定義,但要覺得".sh"結尾便可!編寫後從新鏈接shell時當即生效! PS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\H\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" [23:57:39 root@node101.yinzhengjie.org.cn ~]#
五.執行命令
輸入命令後回車 提請shell程序找到鍵入命令所對應的可執行程序或代碼,並由其分析後提交 給內核分配資源將其運行起來 在shell中可執行的命令有兩類 內部命令: 由shell自帶的,並且經過某命令形式提供 help 內部命令列表 enable cmd 啓用內部命令 enable –n cmd 禁用內部命令 enable –n 查看全部禁用的內部命令 外部命令: 在文件系統路徑下有對應的可執行程序文件 查看路徑:which -a |--skip-alias ; whereis 區別指定的命令是內部或外部命令 type COMMAND Hash緩存表 系統初始hash表爲空,當外部命令執行時,默認會從PATH路徑下尋找該命令,找到後會將這條命令的路徑記錄到hash表中,當再次使用該命令時,shell解 釋器首先會查看hash表,存在將執行之,若是不存在,將會去PATH路徑下尋找, 利用hash緩存表可大大提升命令的調用速率 hash常見用法 hash 顯示hash緩存 hash -l 顯示hash緩存,可做爲輸入使用 hash -p path name 將命令全路徑path起別名爲name hash -t name 打印緩存中name的路徑 hash -d name 清除name緩存 hash -r 清除緩存
[00:12:56 root@node101.yinzhengjie.org.cn ~]#enable #查看內部命令 enable . enable : enable [ enable alias enable bg enable bind enable break enable builtin enable caller enable cd enable command enable compgen enable complete enable compopt enable continue enable declare enable dirs enable disown enable echo enable enable enable eval enable exec enable exit enable export enable false enable fc enable fg enable getopts enable hash enable help enable history enable jobs enable kill enable let enable local enable logout enable mapfile enable popd enable printf enable pushd enable pwd enable read enable readarray enable readonly enable return enable set enable shift enable shopt enable source enable suspend enable test enable times enable trap enable true enable type enable typeset enable ulimit enable umask enable unalias enable unset enable wait [00:12:58 root@node101.yinzhengjie.org.cn ~]# [00:12:58 root@node101.yinzhengjie.org.cn ~]# [00:13:22 root@node101.yinzhengjie.org.cn ~]#ls -l /bin/bash #內置命令都在bash中提供的。 -rwxr-xr-x. 1 root root 964608 Oct 31 2018 /bin/bash [00:13:41 root@node101.yinzhengjie.org.cn ~]#
[00:15:29 root@node101.yinzhengjie.org.cn ~]#type hostname #hostname是一個外部命令,若是是外部命令type會告訴咱們其存放路徑,內部命令運行速度要比外部命令運行快得多。只不過咱們這個時間咱們對其感知太差了 hostname is hashed (/usr/bin/hostname) [00:15:39 root@node101.yinzhengjie.org.cn ~]# [00:15:40 root@node101.yinzhengjie.org.cn ~]#type echo #echo是內部命令 echo is a shell builtin [00:15:47 root@node101.yinzhengjie.org.cn ~]# [00:17:48 root@node101.yinzhengjie.org.cn ~]#type uname uname is /usr/bin/uname [00:17:57 root@node101.yinzhengjie.org.cn ~]# [00:17:57 root@node101.yinzhengjie.org.cn ~]#type type type is a shell builtin [00:18:04 root@node101.yinzhengjie.org.cn ~]#
[00:20:04 root@node101.yinzhengjie.org.cn ~]#echo $PATH /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [00:20:07 root@node101.yinzhengjie.org.cn ~]# [00:21:11 root@node101.yinzhengjie.org.cn ~]#hash #顯示hash緩存 hits command 2 /usr/bin/hostname 1 /usr/bin/cat 1 /usr/bin/ls [00:21:14 root@node101.yinzhengjie.org.cn ~]#
[00:22:28 root@node101.yinzhengjie.org.cn ~]#hash -l #顯示hash緩存,可做爲輸入使用 builtin hash -p /usr/bin/hostname hostname builtin hash -p /usr/bin/cat cat builtin hash -p /usr/bin/ls ls [00:22:30 root@node101.yinzhengjie.org.cn ~]#
[00:23:50 root@node101.yinzhengjie.org.cn ~]#hash hits command 2 /usr/bin/hostname 1 /usr/bin/cat 1 /usr/bin/ls [00:23:51 root@node101.yinzhengjie.org.cn ~]# [00:23:52 root@node101.yinzhengjie.org.cn ~]#hash -r #清空緩存 [00:23:53 root@node101.yinzhengjie.org.cn ~]# [00:23:54 root@node101.yinzhengjie.org.cn ~]#hash hash: hash table empty [00:23:54 root@node101.yinzhengjie.org.cn ~]#
[00:26:27 root@node101.yinzhengjie.org.cn ~]#hash hash: hash table empty [00:26:29 root@node101.yinzhengjie.org.cn ~]# [00:26:30 root@node101.yinzhengjie.org.cn ~]#uname -r #查看內核版本 3.10.0-957.el7.x86_64 [00:26:34 root@node101.yinzhengjie.org.cn ~]# [00:26:35 root@node101.yinzhengjie.org.cn ~]#hash #查看當前緩存 hits command 1 /usr/bin/uname [00:26:36 root@node101.yinzhengjie.org.cn ~]# [00:26:37 root@node101.yinzhengjie.org.cn ~]#echo $PATH #查看系統默認的環境變量 /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [00:26:47 root@node101.yinzhengjie.org.cn ~]# [00:26:48 root@node101.yinzhengjie.org.cn ~]#mv /usr/bin/uname /usr/local/bin/ #咱們將uname命令的路徑移動到另外一個目錄中,均在PATH環境變量中 [00:27:01 root@node101.yinzhengjie.org.cn ~]# [00:27:02 root@node101.yinzhengjie.org.cn ~]#uname -r #再次去執行的時候,咱們發現報錯啦,由於它會直接去hash中查找了文件路徑啦,而沒有去PATH中去找! -bash: /usr/bin/uname: No such file or directory [00:27:33 root@node101.yinzhengjie.org.cn ~]# [00:27:37 root@node101.yinzhengjie.org.cn ~]#hash -d uname #因爲hash中存在uname的緩存信息,所以咱們要將這個緩存刪除掉,若是緩存沒有,默認就回去PATH中查找 [00:27:45 root@node101.yinzhengjie.org.cn ~]# [00:27:46 root@node101.yinzhengjie.org.cn ~]#hash hits command 1 /usr/bin/mv [00:27:48 root@node101.yinzhengjie.org.cn ~]# [00:27:49 root@node101.yinzhengjie.org.cn ~]#uname -r #此時咱們再次使用uname查看內核版本,發現好使了 3.10.0-957.el7.x86_64 [00:27:56 root@node101.yinzhengjie.org.cn ~]# [00:27:56 root@node101.yinzhengjie.org.cn ~]#hash #緩存也更新啦~ hits command 1 /usr/bin/mv 1 /usr/local/bin/uname [00:28:00 root@node101.yinzhengjie.org.cn ~]#
[00:34:56 root@node101.yinzhengjie.org.cn ~]#help #內部命令列表 GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu) These shell commands are defined internally. Type `help' to see this list. Type `help name' to find out more about the function `name'. Use `info bash' to find out more about the shell in general. Use `man -k' or `info' to find out more about commands not in this list. A star (*) next to a name means that the command is disabled. job_spec [&] history [-c] [-d offset] [n] or history -anrw [filen> (( expression )) if COMMANDS; then COMMANDS; [ elif COMMANDS; then CO> . filename [arguments] jobs [-lnprs] [jobspec ...] or jobs -x command [args> : kill [-s sigspec | -n signum | -sigspec] pid | jobsp> [ arg... ] let arg [arg ...] [[ expression ]] local [option] name[=value] ... alias [-p] [name[=value] ... ] logout [n] bg [job_spec ...] mapfile [-n count] [-O origin] [-s count] [-t] [-u f> bind [-lpvsPVS] [-m keymap] [-f filename] [-q name] [> popd [-n] [+N | -N] break [n] printf [-v var] format [arguments] builtin [shell-builtin [arg ...]] pushd [-n] [+N | -N | dir] caller [expr] pwd [-LP] case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]...> read [-ers] [-a array] [-d delim] [-i text] [-n ncha> cd [-L|[-P [-e]]] [dir] readarray [-n count] [-O origin] [-s count] [-t] [-u> command [-pVv] command [arg ...] readonly [-aAf] [name[=value] ...] or readonly -p compgen [-abcdefgjksuv] [-o option] [-A action] [-G > return [n] complete [-abcdefgjksuv] [-pr] [-DE] [-o option] [-A > select NAME [in WORDS ... ;] do COMMANDS; done compopt [-o|+o option] [-DE] [name ...] set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg > continue [n] shift [n] coproc [NAME] command [redirections] shopt [-pqsu] [-o] [optname ...] declare [-aAfFgilrtux] [-p] [name[=value] ...] source filename [arguments] dirs [-clpv] [+N] [-N] suspend [-f] disown [-h] [-ar] [jobspec ...] test [expr] echo [-neE] [arg ...] time [-p] pipeline enable [-a] [-dnps] [-f filename] [name ...] times eval [arg ...] trap [-lp] [[arg] signal_spec ...] exec [-cl] [-a name] [command [arguments ...]] [redir> true exit [n] type [-afptP] name [name ...] export [-fn] [name[=value] ...] or export -p typeset [-aAfFgilrtux] [-p] name[=value] ... false ulimit [-SHacdefilmnpqrstuvx] [limit] fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep> umask [-p] [-S] [mode] fg [job_spec] unalias [-a] name [name ...] for NAME [in WORDS ... ] ; do COMMANDS; done unset [-f] [-v] [name ...] for (( exp1; exp2; exp3 )); do COMMANDS; done until COMMANDS; do COMMANDS; done function name { COMMANDS ; } or name () { COMMANDS ; > variables - Names and meanings of some shell variabl> getopts optstring name [arg] wait [id] hash [-lr] [-p pathname] [-dt] [name ...] while COMMANDS; do COMMANDS; done help [-dms] [pattern ...] { COMMANDS ; } [00:34:57 root@node101.yinzhengjie.org.cn ~]#
[00:39:03 root@node101.yinzhengjie.org.cn ~]#which echo #查看程序的運行路徑 /usr/bin/echo [00:39:09 root@node101.yinzhengjie.org.cn ~]# [00:39:09 root@node101.yinzhengjie.org.cn ~]#whereis echo #除了查看程序的運行路徑,還會列出該程序的幫助文檔存放路徑 echo: /usr/bin/echo /usr/share/man/man1/echo.1.gz /usr/share/man/man1p/echo.1p.gz [00:39:14 root@node101.yinzhengjie.org.cn ~]#
六.命名別名
1>.顯示當前shell進程全部可用的命令別名
[16:39:10 root@node101.yinzhengjie.org.cn ~]#alias alias cp='cp -i' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [16:39:12 root@node101.yinzhengjie.org.cn ~]#
2>.定義別名cdnet,其至關於執行命令VALUE(在命令行中定義的別名,僅對當前shell進程有效 )
[16:42:56 root@node101.yinzhengjie.org.cn ~]#alias cdnet='cd /etc/sysconfig/network-scripts/' #定義一個別名爲cdnet,當用戶執行"cdnet"指令時,就會去執行"cd /etc/sysconfig/network-script" [16:43:12 root@node101.yinzhengjie.org.cn ~]# [16:43:14 root@node101.yinzhengjie.org.cn ~]#alias alias cdnet='cd /etc/sysconfig/network-scripts/' #咱們發現一旦在命令行中定義了別名會當即生效 alias cp='cp -i' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [16:43:18 root@node101.yinzhengjie.org.cn ~]# [16:43:20 root@node101.yinzhengjie.org.cn ~]#cdnet #咱們這裏試着執行了一下咱們定義的別名"cdnet",發現的確是執行成功啦! [16:43:25 root@node101.yinzhengjie.org.cn network-scripts]# [16:43:26 root@node101.yinzhengjie.org.cn network-scripts]#pwd #很顯然,的確是按照咱們的指令去執行的,並且與之前要敲擊不少字符的命令如今只須要五個字母就搞定啦! /etc/sysconfig/network-scripts [16:43:31 root@node101.yinzhengjie.org.cn network-scripts]#
[root@node101.yinzhengjie.org.cn ~]# alias cdnet #查看咱們定義的指定別名 alias cdnet='cd /etc/sysconfig/network-scripts/' [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# type cdnet #不難發現咱們定義的cdnet不屬於內置命令也不是外部命令,而是一個別名 cdnet is aliased to `cd /etc/sysconfig/network-scripts/' [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# enable #查看內部命令 enable . enable : enable [ enable alias enable bg enable bind enable break enable builtin enable caller enable cd enable command enable compgen enable complete enable compopt enable continue enable declare enable dirs enable disown enable echo enable enable enable eval enable exec enable exit enable export enable false enable fc enable fg enable getopts enable hash enable help enable history enable jobs enable kill enable let enable local enable logout enable mapfile enable popd enable printf enable pushd enable pwd enable read enable readarray enable readonly enable return enable set enable shift enable shopt enable source enable suspend enable test enable times enable trap enable true enable type enable typeset enable ulimit enable umask enable unalias enable unset enable wait [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# hostname #查看主機名稱,它是一個外部命令 node101.yinzhengjie.org.cn [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# alias enable=hostname #咱們把一個內置命令enable的變量名賦值給hostname命令,觀察結果 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# enable #不難發現,咱們執行命令時,他居然顯示的時hostname的結果,所以咱們可用總結一下Linux命令執行的順序啦~ node101.yinzhengjie.org.cn [root@node101.yinzhengjie.org.cn ~]#
通過以前的學習,以及剛剛學習的alias,咱們不難發現命令執行的順序爲: 1>.檢查是不是別名,若是是就執行別名定義的命名; 2>.若是別名中找不到就查看是不是內部命令,若是是就執行內部命令; 3>.查看在HASH表中是否存在,若是存在就執行HASH表中的緩存命令; 4>.若是在上面三種都沒有匹配上就去$PATH中查找對應的路徑; 5>.若是以上都找不到命令的話,那就只能拋出"command not found..."這樣的提示啦!
3>.若是想讓定義別名永久有效,要定義在配置文件中
[root@node101.yinzhengjie.org.cn ~]# alias alias cp='cp -i' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# cat .bashrc #當前用戶爲root,咱們發現root用戶有本身默認的alias別名。 # .bashrc # User specific aliases and functions alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# vi .bashrc [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# cat .bashrc # .bashrc # User specific aliases and functions alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' alias cdnet='cd /etc/sysconfig/network-scripts/' #咱們編輯"~/.bashrc"文件,而後添加咱們對應的alias。 # Source global definitions if [ -f /etc/bashrc ]; then #很顯然,在文件的末尾會加載"/etc/bashrc"文件,所以咱們可用在該配置文件中定義alias,若是在該文件中定義會對全部用戶生效! . /etc/bashrc fi [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# source .bashrc #修改配置文件後,想要當即生效的話,得使用source命令或者"."命令進行加載配置文件 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# alias alias cdnet='cd /etc/sysconfig/network-scripts/' #很顯然加載成功啦~ alias cp='cp -i' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# tail -2 /etc/bashrc #咱們可用在"/etc/bashrc"配置文件中修改該值,定義相應的別名。可是針對的是操做系統的全部用戶 #ADD BY YINZHENGJIE alias cdnet='cd /etc/sysconfig/network-scripts/' [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# . /etc/bashrc [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# alias alias cdnet='cd /etc/sysconfig/network-scripts/' alias cp='cp -i' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [root@node101.yinzhengjie.org.cn ~]#
4>.撤消別名:unalias
[root@node101.yinzhengjie.org.cn ~]# alias alias cdnet='cd /etc/sysconfig/network-scripts/' #咱們發現這裏是我們自定義的別名 alias cp='cp -i' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# unalias cdnet #咱們使用該命令就可用刪除別名 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# alias #查看別名是否刪除成功啦~ alias cp='cp -i' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# alias alias cdnet='cd /etc/sysconfig/network-scripts/' alias cp='cp -i' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# unalias -a #取消全部別名,包括默認的別名也會被取消。再命令行執行的話僅對當前終端生效! [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# alias #取消全部的別名後,咱們發現再查看定義的別名時,一個都沒有啦! [root@node101.yinzhengjie.org.cn ~]#
5>.若是別名同原命令同名,若是要執行原命令案例
[root@node101.yinzhengjie.org.cn ~]# hostname node101.yinzhengjie.org.cn [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# alias cd=hostname #咱們知道"cd"命令是切換路徑,可是咱們卻強行把"hostname"命令強行賦值給它 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# cd #不難發現,此時咱們執行"cd"命令它不能執行它以前的切換路徑的做用啦 node101.yinzhengjie.org.cn [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# 'cd' /etc/sysconfig/network-scripts/ #若是咱們非要強行執行"cd"原來的命令的話,可用使用單引號將其括起來,而後就可用完成切換的做用啦 [root@node101.yinzhengjie.org.cn /etc/sysconfig/network-scripts]# [root@node101.yinzhengjie.org.cn /etc/sysconfig/network-scripts]# [root@node101.yinzhengjie.org.cn /etc/sysconfig/network-scripts]# \cd /etc/ #除了上面使用單引號,還可使用反斜線的方式,執行"cd"原來的意思,即不適用別名的定義的命令 [root@node101.yinzhengjie.org.cn /etc]# [root@node101.yinzhengjie.org.cn /etc]# unalias cd #處理上面兩種方法可用執行"cd"原來的意思,其實咱們還可用更乾脆的將別名刪除便可呀~ [root@node101.yinzhengjie.org.cn /etc]# [root@node101.yinzhengjie.org.cn /etc]# cd /root/ #刪除別名後,發現cd命令可用正常執行啦~ [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# alias alias cdnet='cd /etc/sysconfig/network-scripts/' alias cp='cp -i' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' #咱們不難發現,這裏有which相應的別名定義。 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# which ls alias ls='ls --color=auto' /usr/bin/ls [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# which --skip-alias ls #咱們可用跳過全部的別名設置,直接執行which的初始定義 /usr/bin/ls [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# \which ls #固然咱們可用用反斜線也是可用的,咱們在上面已經介紹過啦 /usr/bin/ls [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# 'which' ls #除此以外,咱們還可用使用反引號來執行which的原意命令 /usr/bin/ls [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
七.命令格式
1>.標準格式
COMMAND [OPTIONS...] [ARGUMENTS...] 須要注意的是,"[]"表示可選項,也就是說OPTIONS和ARGUMENTS均可用不存在。
2>.選項[OPTIONS]
用於啓用或關閉命令的某個或某些功能.
短選項:UNIX 風格選項,-c 例如:-l, -h
長選項:GNU風格選項,--word 例如:--all, --human
BSD風格選項: 一個字母,例如:a
[root@node101.yinzhengjie.org.cn ~]# uname -r 3.10.0-957.el7.x86_64 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# id -u 0 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# free -h total used free shared buff/cache available Mem: 3.7G 756M 1.3G 24M 1.6G 2.6G Swap: 3.9G 0B 3.9G [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# fdisk -l Disk /dev/sda: 536.9 GB, 536870912000 bytes, 1048576000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000b26be Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 1048575999 523238400 8e Linux LVM Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/centos-swap: 4160 MB, 4160749568 bytes, 8126464 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/centos-home: 477.9 GB, 477940940800 bytes, 933478400 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# free --si total used free shared buff/cache available Mem: 3861512 775308 1377132 25004 1709072 2747452 Swap: 4063228 0 4063228 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ls --all . .bash_history .bashrc .cshrc Documents .ICEauthority Music .tcshrc .. .bash_logout .cache .dbus Downloads initial-setup-ks.cfg Pictures Templates anaconda-ks.cfg .bash_profile .config Desktop .esd_auth .local Public Videos [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# which --skip-alias pwd /usr/bin/pwd [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:be:11:4d brd ff:ff:ff:ff:ff:ff inet 172.30.1.101/24 brd 172.30.1.255 scope global noprefixroute ens33 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:febe:114d/64 scope link valid_lft forever preferred_lft forever 3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:a9:de:9b brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000 link/ether 52:54:00:a9:de:9b brd ff:ff:ff:ff:ff:ff [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.1 193832 6904 ? Ss Aug02 0:03 /usr/lib/systemd/systemd --switched-root --sys root 2 0.0 0.0 0 0 ? S Aug02 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S Aug02 0:00 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S< Aug02 0:00 [kworker/0:0H] root 7 0.0 0.0 0 0 ? S Aug02 0:00 [migration/0] root 8 0.0 0.0 0 0 ? S Aug02 0:00 [rcu_bh] root 9 0.0 0.0 0 0 ? S Aug02 0:02 [rcu_sched] root 10 0.0 0.0 0 0 ? S< Aug02 0:00 [lru-add-drain] root 11 0.0 0.0 0 0 ? S Aug02 0:00 [watchdog/0] root 12 0.0 0.0 0 0 ? S Aug02 0:00 [watchdog/1] root 13 0.0 0.0 0 0 ? S Aug02 0:00 [migration/1] root 14 0.0 0.0 0 0 ? S Aug02 0:00 [ksoftirqd/1] root 15 0.0 0.0 0 0 ? S Aug02 0:01 [kworker/1:0] root 16 0.0 0.0 0 0 ? S< Aug02 0:00 [kworker/1:0H] root 17 0.0 0.0 0 0 ? S Aug02 0:00 [watchdog/2] root 18 0.0 0.0 0 0 ? S Aug02 0:00 [migration/2] root 19 0.0 0.0 0 0 ? S Aug02 0:00 [ksoftirqd/2] root 21 0.0 0.0 0 0 ? S< Aug02 0:00 [kworker/2:0H] root 22 0.0 0.0 0 0 ? S Aug02 0:00 [watchdog/3] root 23 0.0 0.0 0 0 ? S Aug02 0:00 [migration/3] root 24 0.0 0.0 0 0 ? S Aug02 0:00 [ksoftirqd/3] root 26 0.0 0.0 0 0 ? S< Aug02 0:00 [kworker/3:0H] root 28 0.0 0.0 0 0 ? S Aug02 0:00 [kdevtmpfs] root 29 0.0 0.0 0 0 ? S< Aug02 0:00 [netns] root 30 0.0 0.0 0 0 ? S Aug02 0:00 [khungtaskd] root 31 0.0 0.0 0 0 ? S< Aug02 0:00 [writeback] root 32 0.0 0.0 0 0 ? S< Aug02 0:00 [kintegrityd] root 33 0.0 0.0 0 0 ? S< Aug02 0:00 [bioset] root 34 0.0 0.0 0 0 ? S< Aug02 0:00 [bioset] root 35 0.0 0.0 0 0 ? S< Aug02 0:00 [bioset] root 36 0.0 0.0 0 0 ? S< Aug02 0:00 [kblockd] root 37 0.0 0.0 0 0 ? S< Aug02 0:00 [md] root 38 0.0 0.0 0 0 ? S< Aug02 0:00 [edac-poller] root 39 0.0 0.0 0 0 ? S< Aug02 0:00 [watchdogd] root 40 0.0 0.0 0 0 ? S Aug02 0:01 [kworker/2:1] root 41 0.0 0.0 0 0 ? S Aug02 0:00 [kworker/3:1] root 47 0.0 0.0 0 0 ? S Aug02 0:00 [kswapd0] root 48 0.0 0.0 0 0 ? SN Aug02 0:00 [ksmd] root 49 0.0 0.0 0 0 ? SN Aug02 0:00 [khugepaged] root 50 0.0 0.0 0 0 ? S< Aug02 0:00 [crypto] root 58 0.0 0.0 0 0 ? S< Aug02 0:00 [kthrotld] root 59 0.0 0.0 0 0 ? S Aug02 0:00 [kworker/u256:1] root 60 0.0 0.0 0 0 ? S< Aug02 0:00 [kmpath_rdacd] root 61 0.0 0.0 0 0 ? S< Aug02 0:00 [kaluad] root 62 0.0 0.0 0 0 ? S< Aug02 0:00 [kpsmoused] root 64 0.0 0.0 0 0 ? S< Aug02 0:00 [ipv6_addrconf] root 77 0.0 0.0 0 0 ? S< Aug02 0:00 [deferwq] root 110 0.0 0.0 0 0 ? S Aug02 0:00 [kauditd] root 258 0.0 0.0 0 0 ? S Aug02 0:00 [kworker/2:2] root 601 0.0 0.0 0 0 ? S Aug02 0:00 [kworker/3:2] root 2752 0.0 0.0 0 0 ? S< Aug02 0:00 [nfit] root 2793 0.0 0.0 0 0 ? S< Aug02 0:00 [ata_sff] root 2805 0.0 0.0 0 0 ? S< Aug02 0:00 [mpt_poll_0] root 2821 0.0 0.0 0 0 ? S< Aug02 0:00 [mpt/0] root 3031 0.0 0.0 0 0 ? S Aug02 0:00 [scsi_eh_0] root 3036 0.0 0.0 0 0 ? S< Aug02 0:00 [scsi_tmf_0] root 3163 0.0 0.0 0 0 ? S Aug02 0:00 [scsi_eh_1] root 3196 0.0 0.0 0 0 ? S< Aug02 0:00 [scsi_tmf_1] root 3203 0.0 0.0 0 0 ? S Aug02 0:00 [scsi_eh_2] root 3209 0.0 0.0 0 0 ? S< Aug02 0:00 [scsi_tmf_2] root 3222 0.0 0.0 0 0 ? S< Aug02 0:00 [ttm_swap] root 3227 0.0 0.0 0 0 ? S Aug02 0:00 [irq/16-vmwgfx] root 4254 0.0 0.0 0 0 ? S< Aug02 0:00 [kdmflush] root 4257 0.0 0.0 0 0 ? S< Aug02 0:00 [bioset] root 4270 0.0 0.0 0 0 ? S< Aug02 0:00 [kdmflush] root 4273 0.0 0.0 0 0 ? S< Aug02 0:00 [bioset] root 4290 0.0 0.0 0 0 ? S< Aug02 0:00 [bioset] root 4298 0.0 0.0 0 0 ? S< Aug02 0:00 [xfsalloc] root 4299 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs_mru_cache] root 4307 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-buf/dm-0] root 4308 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-data/dm-0] root 4309 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-conv/dm-0] root 4311 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-cil/dm-0] root 4312 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-reclaim/dm-] root 4314 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-log/dm-0] root 4315 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-eofblocks/d] root 4316 0.0 0.0 0 0 ? S Aug02 0:03 [xfsaild/dm-0] root 4317 0.0 0.0 0 0 ? S< Aug02 0:00 [kworker/0:1H] root 4390 0.0 0.1 39824 6136 ? Ss Aug02 0:00 /usr/lib/systemd/systemd-journald root 4411 0.0 0.1 192884 5416 ? Ss Aug02 0:00 /usr/sbin/lvmetad -f root 4426 0.0 0.1 49520 6856 ? Ss Aug02 0:01 /usr/lib/systemd/systemd-udevd root 7347 0.0 0.0 0 0 ? S< Aug02 0:00 [kworker/u257:0] root 7350 0.0 0.0 0 0 ? S< Aug02 0:00 [hci0] root 7351 0.0 0.0 0 0 ? S< Aug02 0:00 [hci0] root 7355 0.0 0.0 0 0 ? S< Aug02 0:00 [kworker/u257:2] root 7612 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-buf/sda1] root 7618 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-data/sda1] root 7634 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-conv/sda1] root 7642 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-cil/sda1] root 7659 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-reclaim/sda] root 7664 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-log/sda1] root 7673 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-eofblocks/s] root 7682 0.0 0.0 0 0 ? S Aug02 0:00 [xfsaild/sda1] root 8644 0.0 0.0 0 0 ? S< Aug02 0:00 [kdmflush] root 8647 0.0 0.0 0 0 ? S< Aug02 0:00 [bioset] root 8654 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-buf/dm-2] root 8655 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-data/dm-2] root 8656 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-conv/dm-2] root 8657 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-cil/dm-2] root 8658 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-reclaim/dm-] root 8659 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-log/dm-2] root 8662 0.0 0.0 0 0 ? S< Aug02 0:00 [xfs-eofblocks/d] root 8663 0.0 0.0 0 0 ? S Aug02 0:00 [xfsaild/dm-2] root 8698 0.0 0.0 62044 1084 ? S<sl Aug02 0:00 /sbin/auditd root 8700 0.0 0.0 84552 2968 ? S<sl Aug02 0:00 /sbin/audispd root 8702 0.0 0.0 55632 1664 ? S< Aug02 0:00 /usr/sbin/sedispatch root 8703 0.0 0.0 0 0 ? S< Aug02 0:00 [rpciod] root 8704 0.0 0.0 0 0 ? S< Aug02 0:00 [xprtiod] avahi 8731 0.0 0.0 62268 2272 ? Ss Aug02 0:00 avahi-daemon: running [node101.local] root 8732 0.0 0.0 21676 1300 ? Ss Aug02 0:05 /usr/sbin/irqbalance --foreground rpc 8733 0.0 0.0 73648 1376 ? Ss Aug02 0:00 /sbin/rpcbind -w dbus 8734 0.0 0.1 70996 4492 ? Ssl Aug02 0:02 /usr/bin/dbus-daemon --system --address=system avahi 8735 0.0 0.0 62144 396 ? S Aug02 0:00 avahi-daemon: chroot helper rtkit 8737 0.0 0.0 198792 1652 ? SNsl Aug02 0:01 /usr/libexec/rtkit-daemon root 8738 0.0 0.0 90392 3204 ? Ss Aug02 0:02 /sbin/rngd -f root 8739 0.0 0.0 24492 2284 ? Ss Aug02 0:00 /usr/sbin/smartd -n -q never root 8740 0.0 0.2 453456 8756 ? Ssl Aug02 0:00 /usr/libexec/udisks2/udisksd root 8741 0.0 0.1 430600 5536 ? Ssl Aug02 0:00 /usr/sbin/ModemManager root 8743 0.0 0.0 26376 1816 ? Ss Aug02 0:00 /usr/lib/systemd/systemd-logind root 8744 0.0 0.1 228048 5620 ? Ss Aug02 0:00 /usr/sbin/abrtd -d -s root 8747 0.0 0.1 225720 4828 ? Ss Aug02 0:00 /usr/bin/abrt-watch-log -F Backtrace /var/log/ root 8748 0.0 0.1 225720 4824 ? Ss Aug02 0:00 /usr/bin/abrt-watch-log -F BUG: WARNING: at WA root 8749 0.0 0.0 57512 2816 ? Ss Aug02 0:00 /usr/libexec/bluetooth/bluetoothd polkitd 8750 0.0 0.3 616508 14584 ? Ssl Aug02 0:00 /usr/lib/polkit-1/polkitd --no-debug libstor+ 8751 0.0 0.0 8576 828 ? Ss Aug02 0:00 /usr/bin/lsmd -d root 8755 0.0 0.0 16892 1392 ? SNs Aug02 0:00 /usr/sbin/alsactl -s -n 19 -c -E ALSA_CONFIG_P root 8757 0.0 0.1 396352 4104 ? Ssl Aug02 0:00 /usr/libexec/accounts-daemon root 8760 0.0 0.1 99568 6116 ? Ss Aug02 0:00 /usr/bin/VGAuthService -s root 8761 0.1 0.1 320028 6744 ? Ssl Aug02 0:47 /usr/bin/vmtoolsd root 8781 0.0 0.0 207828 1476 ? Ssl Aug02 0:00 /usr/sbin/gssproxy -D root 8840 0.0 0.0 115304 956 ? S Aug02 0:01 /bin/bash /usr/sbin/ksmtuned root 8847 0.0 0.7 358192 29180 ? Ssl Aug02 0:00 /usr/bin/python -Es /usr/sbin/firewalld --nofo root 8897 0.0 0.0 0 0 ? S< Aug02 0:00 [kworker/2:1H] root 8907 0.0 0.2 563132 9292 ? Ssl Aug02 0:00 /usr/sbin/NetworkManager --no-daemon root 8937 0.0 0.0 0 0 ? S< Aug02 0:00 [kworker/3:1H] root 9386 0.0 0.1 112756 4324 ? Ss Aug02 0:00 /usr/sbin/sshd -D root 9387 0.0 0.4 573824 19300 ? Ssl Aug02 0:06 /usr/bin/python2 -Es /usr/sbin/tuned -l -P root 9388 0.0 0.1 197880 4208 ? Ss Aug02 0:00 /usr/sbin/cupsd -f root 9391 0.0 0.1 216408 6044 ? Ssl Aug02 0:03 /usr/sbin/rsyslogd -n root 9395 0.0 0.4 1005992 18324 ? Ssl Aug02 0:00 /usr/sbin/libvirtd root 9404 0.0 0.0 126284 1708 ? Ss Aug02 0:00 /usr/sbin/crond -n root 9405 0.0 0.1 481324 4732 ? Ssl Aug02 0:00 /usr/sbin/gdm root 9406 0.0 0.0 25904 948 ? Ss Aug02 0:00 /usr/sbin/atd -f root 9752 0.0 0.0 91628 2244 ? Ss Aug02 0:00 /usr/libexec/postfix/master -w postfix 9761 0.0 0.1 91800 4116 ? S Aug02 0:00 qmgr -l -t unix -u nobody 9777 0.0 0.0 53884 1108 ? S Aug02 0:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt root 9778 0.0 0.0 53856 380 ? S Aug02 0:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt root 10066 0.0 1.2 353632 46528 tty1 Ssl+ Aug02 0:03 /usr/bin/X :0 -background none -noreset -audit root 10080 0.0 0.1 529260 5456 ? Sl Aug02 0:00 gdm-session-worker [pam/gdm-autologin] root 10086 0.0 0.2 745084 9396 ? Ssl Aug02 0:00 /usr/libexec/gnome-session-binary --session gn root 10095 0.0 0.0 59024 968 ? S Aug02 0:00 dbus-launch --sh-syntax --exit-with-session root 10096 0.0 0.0 69316 2724 ? Ssl Aug02 0:00 /usr/bin/dbus-daemon --fork --print-pid 5 --pr root 10173 0.0 0.1 388644 6004 ? Sl Aug02 0:00 /usr/libexec/gvfsd root 10178 0.0 0.0 417808 3292 ? Sl Aug02 0:00 /usr/libexec/gvfsd-fuse /run/user/0/gvfs -f -o root 10275 0.0 0.0 72312 780 ? Ss Aug02 0:00 /usr/bin/ssh-agent /bin/sh -c exec -l /bin/bas root 10300 0.0 0.0 346752 3696 ? Sl Aug02 0:00 /usr/libexec/at-spi-bus-launcher root 10305 0.0 0.0 68400 2484 ? Sl Aug02 0:00 /usr/bin/dbus-daemon --config-file=/usr/share/ root 10308 0.0 0.1 233104 3944 ? Sl Aug02 0:00 /usr/libexec/at-spi2-registryd --use-gnome-ses root 10345 0.0 0.1 317308 4064 ? SLl Aug02 0:00 /usr/bin/gnome-keyring-daemon --start --compon root 10356 0.0 5.3 3690828 205788 ? Sl Aug02 0:20 /usr/bin/gnome-shell root 10363 0.0 0.1 430252 5212 ? Ssl Aug02 0:00 /usr/libexec/upowerd root 10380 0.0 0.0 0 0 ? S< Aug02 0:00 [kworker/1:1H] root 10407 0.0 0.1 452984 5448 ? Sl Aug02 0:00 ibus-daemon --xim --panel disable root 10411 0.0 0.1 375852 5616 ? Sl Aug02 0:00 /usr/libexec/ibus-dconf root 10413 0.0 0.3 464784 13576 ? Sl Aug02 0:00 /usr/libexec/ibus-x11 --kill-daemon root 10418 0.0 0.0 375848 3328 ? Sl Aug02 0:00 /usr/libexec/ibus-portal root 10427 0.0 0.1 364592 4692 ? Sl Aug02 0:00 /usr/libexec/xdg-permission-store root 10430 0.0 0.3 649684 13624 ? Sl Aug02 0:00 /usr/libexec/gnome-shell-calendar-server root 10437 0.0 0.4 1378552 18212 ? Sl Aug02 0:00 /usr/libexec/evolution-source-registry root 10443 0.0 0.7 101566764 27744 ? Sl Aug02 0:00 /usr/libexec/goa-daemon root 10447 0.0 0.0 398376 3796 ? Ssl Aug02 0:00 /usr/libexec/boltd root 10451 0.0 0.0 78560 3348 ? Ss Aug02 0:00 /usr/sbin/wpa_supplicant -u -f /var/log/wpa_su root 10456 0.0 0.2 485256 9724 ? Sl Aug02 0:00 /usr/libexec/mission-control-5 root 10462 0.0 0.1 563260 7376 ? Sl Aug02 0:00 /usr/libexec/gvfs-udisks2-volume-monitor root 10471 0.0 0.1 478400 6444 ? Sl Aug02 0:00 /usr/libexec/gvfs-afc-volume-monitor root 10475 0.0 0.2 532056 10548 ? Sl Aug02 0:03 /usr/libexec/goa-identity-service root 10485 0.0 0.0 400568 3636 ? Sl Aug02 0:00 /usr/libexec/gvfs-gphoto2-volume-monitor root 10492 0.0 0.0 391480 3400 ? Sl Aug02 0:00 /usr/libexec/gvfs-mtp-volume-monitor root 10497 0.0 0.0 371444 3140 ? Sl Aug02 0:00 /usr/libexec/gvfs-goa-volume-monitor root 10501 0.0 0.1 412580 7716 ? Ssl Aug02 0:00 /usr/libexec/packagekitd root 10502 0.0 0.4 631612 16664 ? Sl Aug02 0:00 /usr/libexec/gsd-power root 10504 0.0 0.1 438964 5556 ? Sl Aug02 0:00 /usr/libexec/gsd-print-notifications root 10506 0.0 0.0 521548 2944 ? Sl Aug02 0:00 /usr/libexec/gsd-rfkill root 10510 0.0 0.0 374072 2972 ? Sl Aug02 0:00 /usr/libexec/gsd-screensaver-proxy root 10513 0.0 0.1 558852 5176 ? Sl Aug02 0:00 /usr/libexec/gsd-sharing root 10521 0.0 0.1 454840 4740 ? Sl Aug02 0:00 /usr/libexec/gsd-sound root 10525 0.0 0.3 615060 14736 ? Sl Aug02 0:00 /usr/libexec/gsd-xsettings root 10527 0.0 0.3 557420 14096 ? Sl Aug02 0:00 /usr/libexec/gsd-wacom root 10529 0.0 0.1 472036 5036 ? Sl Aug02 0:00 /usr/libexec/gsd-smartcard root 10531 0.0 0.0 456656 3400 ? Sl Aug02 0:00 /usr/libexec/gsd-account root 10542 0.0 0.0 376328 3240 ? Sl Aug02 0:00 /usr/libexec/gsd-a11y-settings root 10545 0.0 0.3 464404 13360 ? Sl Aug02 0:00 /usr/libexec/gsd-clipboard root 10547 0.0 0.4 705780 16588 ? Sl Aug02 0:05 /usr/libexec/gsd-color root 10548 0.0 0.2 545848 8816 ? Sl Aug02 0:00 /usr/libexec/gsd-datetime root 10551 0.0 0.1 463216 3956 ? Sl Aug02 0:02 /usr/libexec/gsd-housekeeping root 10555 0.0 0.1 1285292 7188 ? S<l Aug02 0:00 /usr/bin/pulseaudio --start root 10557 0.0 0.3 614152 13600 ? Sl Aug02 0:00 /usr/libexec/gsd-keyboard root 10560 0.0 0.4 1142844 17444 ? Sl Aug02 0:00 /usr/libexec/gsd-media-keys root 10564 0.0 0.0 376332 3236 ? Sl Aug02 0:00 /usr/libexec/gsd-mouse root 10595 0.0 0.2 608476 9820 ? Sl Aug02 0:00 /usr/libexec/gsd-printer colord 10614 0.0 0.1 419468 6168 ? Ssl Aug02 0:00 /usr/libexec/colord root 10615 0.0 0.0 0 0 ? S< Aug02 0:00 [krfcommd] root 10622 0.0 0.7 1004644 29216 ? Sl Aug02 0:00 nautilus-desktop --force root 10631 0.0 0.1 464652 4520 ? Sl Aug02 0:00 /usr/libexec/gvfsd-trash --spawner :1.3 /org/g root 10643 0.0 0.5 916396 20040 ? Sl Aug02 0:00 /usr/libexec/evolution-calendar-factory root 10646 0.1 0.6 566640 25984 ? Sl Aug02 0:47 /usr/bin/vmtoolsd -n vmusr root 10648 0.0 0.0 273044 3260 ? Sl Aug02 0:00 /usr/libexec/gsd-disk-utility-notify root 10651 0.0 0.2 309884 9704 ? S Aug02 0:00 /usr/bin/seapplet root 10654 0.0 0.4 530008 16580 ? Sl Aug02 0:00 abrt-applet root 10655 0.0 2.4 118651768 96448 ? Sl Aug02 0:05 /usr/libexec/gnome-initial-setup --existing-us root 10658 0.0 1.5 1277332 59040 ? Sl Aug02 0:03 /usr/bin/gnome-software --gapplication-service root 10668 0.0 0.3 668716 15068 ? SNl Aug02 0:00 /usr/libexec/tracker-extract root 10670 0.0 0.4 1143004 17856 ? Sl Aug02 0:00 /usr/libexec/evolution-calendar-factory-subpro root 10672 0.0 0.2 705980 10276 ? SNl Aug02 0:00 /usr/libexec/tracker-miner-apps root 10679 0.0 0.3 649028 13676 ? SNl Aug02 0:00 /usr/libexec/tracker-miner-fs root 10688 0.0 0.3 561752 11832 ? SNl Aug02 0:00 /usr/libexec/tracker-miner-user-guides root 10715 0.0 0.3 525296 12540 ? Sl Aug02 0:00 /usr/libexec/tracker-store root 10726 0.0 0.4 903120 17436 ? Sl Aug02 0:00 /usr/libexec/evolution-addressbook-factory root 10733 0.0 0.0 187384 2876 ? Sl Aug02 0:00 /usr/libexec/dconf-service root 10795 0.0 0.0 302184 3460 ? Sl Aug02 0:00 /usr/libexec/ibus-engine-simple root 10818 0.0 0.5 1119820 21160 ? Sl Aug02 0:00 /usr/libexec/evolution-addressbook-factory-sub root 10859 0.0 0.2 586136 8488 ? Ssl Aug02 0:01 /usr/libexec/fwupd/fwupd root 11710 0.0 0.0 317740 3300 ? Sl Aug02 0:00 /usr/libexec/gvfsd-metadata root 11718 0.0 0.7 735608 28952 ? Sl Aug02 0:00 /usr/libexec/gnome-terminal-server root 11724 0.0 0.0 8532 732 ? S Aug02 0:00 gnome-pty-helper root 11725 0.0 0.0 116328 3008 pts/0 Ss+ Aug02 0:00 bash root 16291 0.0 0.0 0 0 ? S 00:20 0:00 [kworker/1:2] postfix 16570 0.0 0.1 91732 4096 ? S 00:50 0:00 pickup -l -t unix -u root 16953 0.0 0.0 0 0 ? S 01:30 0:00 [kworker/u256:0] root 17169 0.0 0.1 160848 5608 ? Ds 01:44 0:00 sshd: root@pts/1 root 17173 0.0 0.0 116360 3128 pts/1 Ss 01:44 0:00 -bash root 17321 0.0 0.0 0 0 ? S 01:53 0:00 [kworker/0:0] root 17381 0.0 0.0 0 0 ? S 01:59 0:00 [kworker/0:1] root 17550 0.0 0.0 0 0 ? S 02:15 0:00 [kworker/0:2] root 17552 0.0 0.0 0 0 ? S 02:16 0:00 [kworker/2:0] root 17553 0.0 0.0 0 0 ? S 02:16 0:00 [kworker/2:3] root 17646 0.0 0.0 107952 612 ? S 02:19 0:00 sleep 60 root 17659 0.0 0.0 155360 1892 pts/1 R+ 02:20 0:00 ps aux [root@node101.yinzhengjie.org.cn ~]#
3>.參數[ARGUMENTS]
命令的做用對象,好比文件名,用戶名等. [root@node101.yinzhengjie.org.cn ~]# file anaconda-ks.cfg anaconda-ks.cfg: ASCII text [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# id -u yinzhengjie 1000 [root@node101.yinzhengjie.org.cn ~]#
4>.注意事項
多個選項以及多參數和命令之間使用空白字符分隔
取消和結束命令執行:Ctrl+c,Ctrl+d
多個命令能夠用;符號分開
一個命令能夠用\分紅多行
[root@node101.yinzhengjie.org.cn ~]# bc #進入計算器工具 bc 1.06.95 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. ibase #查看輸入的進制,發現默認的進制也是10. 10 obase #查看輸出的進制,發現默認的進制也是10. 10 ibase=2 11111111 255 ^C #咱們輸入"Ctrl + c"強行退出Linux當前進程 (interrupt) Exiting bc. [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# bc bc 1.06.95 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. obase=2 123 1111011 #咱們發現若是輸入的是"Ctrl +d"的話並不會強制退出,而是正常退出Linux程序 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# logout #不只如此,咱們輸入"Ctrl + d"還可用退出當前終端喲~ Connection closed by foreign host. Disconnected from remote host(node101.yinzhengjie.org.cn) at 18:34:43. Type `help' to learn how to use Xshell prompt. [c:\~]$
[root@node101.yinzhengjie.org.cn ~]# free ;hostname;ifconfig #使用分號能夠同時執行多個命令 total used free shared buff/cache available Mem: 3861512 778336 1371012 25012 1712164 2744272 Swap: 4063228 0 4063228 node101.yinzhengjie.org.cn ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.30.1.101 netmask 255.255.255.0 broadcast 172.30.1.255 inet6 fe80::20c:29ff:febe:114d prefixlen 64 scopeid 0x20<link> ether 00:0c:29:be:11:4d txqueuelen 1000 (Ethernet) RX packets 195215 bytes 277828290 (264.9 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 20084 bytes 1539884 (1.4 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 84 bytes 9156 (8.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 84 bytes 9156 (8.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:a9:de:9b txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# host\ #咱們能夠"\"進行換行,尤爲是在編譯按照http,nginx等之類的服務,配置參數太多了,一行每每寫不下。我這裏爲了方便演示,就把hostname命令分紅2行寫啦! > name node101.yinzhengjie.org.cn [root@node101.yinzhengjie.org.cn ~]#
八.得到幫助
獲取幫助的能力決定了技術的能力! 多層次的幫助 whatis help command #內部命令查看幫助
command --help #外部命令查看幫助 man and info /usr/share/doc/ Red Hat documentation 其它網站和搜索
1>.whatis
顯示命令的簡短描述,能夠對命令進行簡單說明的。 whatis是須要使用數據庫的,咱們查看命令的簡短幫助信息實際上是使用的Linux操做系統內置的數據庫。 剛安裝後不可當即使用,由於數據庫尚未生成(這個數據庫是系統自動生成的,時間是不肯定的,它在操做系統不繁忙的時候會自動生成該數據庫),咱們能夠經過makewhatis(CentOS 6 可用)或者mandb(Centos 7 可用)來手動製做數據庫 使用示例: [root@node101.yinzhengjie.org.cn ~]# whatis rm rm (1) - remove files or directories rm (1p) - remove directory entries [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# mandb Purging old database entries in /usr/share/man... mandb: warning: /usr/share/man/man8/fsck.fat.8.manpage-fix.gz: ignoring bogus filename Processing manual pages under /usr/share/man... Purging old database entries in /usr/share/man/uk... Processing manual pages under /usr/share/man/uk... Purging old database entries in /usr/share/man/hu... Processing manual pages under /usr/share/man/hu... Purging old database entries in /usr/share/man/de... Processing manual pages under /usr/share/man/de... Purging old database entries in /usr/share/man/ja... Processing manual pages under /usr/share/man/ja... Purging old database entries in /usr/share/man/fr... Processing manual pages under /usr/share/man/fr... Purging old database entries in /usr/share/man/ko... Processing manual pages under /usr/share/man/ko... Purging old database entries in /usr/share/man/pl... Processing manual pages under /usr/share/man/pl... Purging old database entries in /usr/share/man/ru... Processing manual pages under /usr/share/man/ru... Purging old database entries in /usr/share/man/sk... Processing manual pages under /usr/share/man/sk... Purging old database entries in /usr/share/man/cs... Processing manual pages under /usr/share/man/cs... Purging old database entries in /usr/share/man/da... Processing manual pages under /usr/share/man/da... Purging old database entries in /usr/share/man/id... Processing manual pages under /usr/share/man/id... Purging old database entries in /usr/share/man/it... Processing manual pages under /usr/share/man/it... Purging old database entries in /usr/share/man/pt_BR... Processing manual pages under /usr/share/man/pt_BR... Purging old database entries in /usr/share/man/sv... Processing manual pages under /usr/share/man/sv... Purging old database entries in /usr/share/man/tr... Processing manual pages under /usr/share/man/tr... Purging old database entries in /usr/share/man/zh_CN... Processing manual pages under /usr/share/man/zh_CN... Purging old database entries in /usr/share/man/zh_TW... Processing manual pages under /usr/share/man/zh_TW... Purging old database entries in /usr/share/man/ca... Processing manual pages under /usr/share/man/ca... Purging old database entries in /usr/share/man/es... Processing manual pages under /usr/share/man/es... Purging old database entries in /usr/share/man/nl... Processing manual pages under /usr/share/man/nl... Purging old database entries in /usr/share/man/pt... Processing manual pages under /usr/share/man/pt... Purging old database entries in /usr/share/man/overrides... Processing manual pages under /usr/share/man/overrides... Purging old database entries in /usr/share/man/en... Processing manual pages under /usr/share/man/en... Purging old database entries in /usr/local/share/man... Processing manual pages under /usr/local/share/man... 0 man subdirectories contained newer manual pages. 0 manual pages were added. 0 stray cats were added. 0 old database entries were purged. [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# whatis date date (1) - print or set the system date and time date (1p) - write the date and time [root@node101.yinzhengjie.org.cn ~]#
2>.內部命令的幫助信息
[root@node101.yinzhengjie.org.cn ~]# type help #不難發現,help命令自己就是內部命令 help is a shell builtin [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# type echo #不難發現,使用type命令能夠查看到echo命令是內部命令 echo is a shell builtin [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# type date #而date命令不是內部命令,而是外部命令 date is hashed (/usr/bin/date) [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# help date #咱們使用help命令是沒有辦法去查看外部命令的幫助信息的 -bash: help: no help topics match `date'. Try `help help' or `man -k date' or `info date'. [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# help echo #不難總結出help命令只能用來查看內部命令喲~ echo: echo [-neE] [arg ...] #這裏是echo命令的格式 Write arguments to the standard output. #寫參數到標準輸出,說白了就是把參數輸出到當前屏幕中。 Display the ARGs on the standard output followed by a newline. #它會顯示參數到標準輸出並換行。 Options: #選項 -n do not append a newline #不添加換行,默認是在參數結尾換行。 -e enable interpretation of the following backslash escapes #啓用"\"字符的解釋功能 -E explicitly suppress interpretation of backslash escapes #(默認)不支持"\"解釋功能 `echo' interprets the following backslash-escaped characters: \a alert (bell) #操做系統會發出警告聲 \b backspace #退格鍵,若是後面有數據的話會刪除前面一個字符 \c suppress further output #最後不加上換行符,能夠取消換行,和-n效果相似 \e escape character #escape,至關於\033 \f form feed #和縱向製表符相似 \n new line #添加換行,換行且將光標移至行首 \r carriage return #回車,即將光標移至行首,但不換行 \t horizontal tab #製表符,通常爲4個連續的空格 \v vertical tab #縱向的製表符 \\ backslash #咱們知道"\"時轉義符,想要打印反斜線的話,就得使用轉義符。 \0nnn the character whose ASCII code is NNN (octal). NNN can be to 3 octal digits #插入nnn(八進制)所表明的ASCII字符 \xHH the eight-bit character whose value is HH (hexadecimal). HH can be one or two hex digits #插入HH(十六進制)所表明的ASCII數字 Exit Status: Returns success unless a write error occurs. [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "\a" #執行該命令時,你會發現你的服務器若是有聲卡的話會發出一個提示音!!! [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "abc\bxyz" #咱們發現字符c被刪除啦 abxyz [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "abc\c" #咱們不難發現,默認的換行符被取消啦! abc[root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "abc\n123\nxyz" #注意,這裏有2個換行符 abc 123 xyz [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "yinzhengjie\t2019\tjason" #讓字符之間距離間隔一個製表符 yinzhengjie 2019 jason [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "yinzhengjie\v2019\vjason" #咱們可使用縱向的製表符,咱們發現數據原本應該連續寫的,可是使用縱向製表符後,數據居然換換行且未到行的首部! yinzhengjie 2019 jason [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# echo -e "yinzhengjie\v2019\vjason" | wc -l #咱們使用換行的命令統計改行的大小,返現其僅爲1行內容。 1 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "yinzhengjie\f2019\ejason" yinzhengjie 2019ason [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "yinzhengjie\f2019\fjason" yinzhengjie 2019 jason [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "yinzhengjie\r2019" #不難發現,咱們進行回車後,以前的數據被覆蓋掉啦,由於我沒有換行,直接將光標移至行首了,新數據會把以前的數據覆蓋! 2019hengjie [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "\\" #打印反斜線 \ [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "\0101" #使用8進制的方式查看101數字對應的字符 A [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# echo -e "\0102" B [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# echo -e "\0103" C [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "\x41" #使用16進制查看數字41對應的字符 A [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# echo -e "\x42" B [root@node101.yinzhengjie.org.cn ~]# echo -e "\x43" C [root@node101.yinzhengjie.org.cn ~]#
ASCII碼: 計算機內部,全部信息最終都是一個二進制值。上個世紀60年代,美國製定了一套字符編碼,對英語字符與二進制位之間的關係,作了統一規定。 ASCII碼一共規定了128個字符的編碼,佔用了一個字節的後面7位,最前面的一位統一規定爲0 Unicode: 用於表示世界上全部語言中的全部字符。每個符號都給予一個獨一無二的編碼數字,Unicode是一個很大的集合,如今的規模能夠容納100多萬個符號。Unicode僅僅只是一個字符集,規定了每一個字符對應的二進制代碼,至於這個二進制代碼如何存儲則沒有規定 Unicode編碼方案:(咱們能夠形象的比喻,Unicode編碼只是告訴全世界這個字該怎麼寫,可是以哪一種方式編碼它推出瞭如下幾種解決方案,儘管你使用的時GBK或者UTF-8編碼,可是在內存中的數據均是萬國碼Unicode。) UTF-8:變長,1到4個字節 UTF-16:變長,2或4個字節 UTF-32:固定長度,4個字節 UTF-8編碼 是目前互聯網上使用最普遍的一種Unicode編碼方式,可變長存儲。使用 1 - 4 個字節表示一個字符,根據字符的不一樣變換長度。編碼規則以下: 對於單個字節的字符,第一位設爲0,後面的7位對應這個字符的Unicode碼。所以,對於英文中的0 - 127號字符,與ASCII碼徹底相同。這意味着ASCII碼的文檔可用UTF-8編碼打開 對於須要使用N個字節來表示的字符(N>1),第一個字節的前N位都設爲1,第「N+1」位設爲0,剩餘的「N-1」個字節的前兩位都設位10,剩下的二進制位則使用這個字符的Unicode碼來填充 編碼轉換和查詢: http://www.chi2ko.com/tool/CJK.htm https://javawind.net/tools/native2ascii.jsp?action=transform http://tool.oschina.net/encode Linux系統查看當前操做系統正在使用的編碼方法以下: [root@node101.yinzhengjie.org.cn ~]# echo $LANG en_US.UTF-8 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# man ascii ASCII(7) Linux Programmer's Manual ASCII(7) NAME ascii - ASCII character set encoded in octal, decimal, and hexadecimal DESCRIPTION ASCII is the American Standard Code for Information Interchange. It is a 7-bit code. Many 8-bit codes (such as ISO 8859-1, the Linux default character set) contain ASCII as their lower half. The international counterpart of ASCII is known as ISO 646. The following table contains the 128 ASCII characters. C program '\X' escapes are noted. Oct Dec Hex Char Oct Dec Hex Char ──────────────────────────────────────────────────────────────────────── 000 0 00 NUL '\0' 100 64 40 @ 001 1 01 SOH (start of heading) 101 65 41 A 002 2 02 STX (start of text) 102 66 42 B 003 3 03 ETX (end of text) 103 67 43 C 004 4 04 EOT (end of transmission) 104 68 44 D 005 5 05 ENQ (enquiry) 105 69 45 E 006 6 06 ACK (acknowledge) 106 70 46 F 007 7 07 BEL '\a' (bell) 107 71 47 G 010 8 08 BS '\b' (backspace) 110 72 48 H 011 9 09 HT '\t' (horizontal tab) 111 73 49 I 012 10 0A LF '\n' (new line) 112 74 4A J 013 11 0B VT '\v' (vertical tab) 113 75 4B K 014 12 0C FF '\f' (form feed) 114 76 4C L 015 13 0D CR '\r' (carriage ret) 115 77 4D M 016 14 0E SO (shift out) 116 78 4E N 017 15 0F SI (shift in) 117 79 4F O 020 16 10 DLE (data link escape) 120 80 50 P 021 17 11 DC1 (device control 1) 121 81 51 Q 022 18 12 DC2 (device control 2) 122 82 52 R 023 19 13 DC3 (device control 3) 123 83 53 S 024 20 14 DC4 (device control 4) 124 84 54 T 025 21 15 NAK (negative ack.) 125 85 55 U 026 22 16 SYN (synchronous idle) 126 86 56 V 027 23 17 ETB (end of trans. blk) 127 87 57 W 030 24 18 CAN (cancel) 130 88 58 X 031 25 19 EM (end of medium) 131 89 59 Y 032 26 1A SUB (substitute) 132 90 5A Z 033 27 1B ESC (escape) 133 91 5B [ 034 28 1C FS (file separator) 134 92 5C \ '\\' 035 29 1D GS (group separator) 135 93 5D ] 036 30 1E RS (record separator) 136 94 5E ^ 037 31 1F US (unit separator) 137 95 5F _ 040 32 20 SPACE 140 96 60 ` 041 33 21 ! 141 97 61 a 042 34 22 " 142 98 62 b 043 35 23 # 143 99 63 c 044 36 24 $ 144 100 64 d 045 37 25 % 145 101 65 e 046 38 26 & 146 102 66 f 047 39 27 ´ 147 103 67 g 050 40 28 ( 150 104 68 h 051 41 29 ) 151 105 69 i 052 42 2A * 152 106 6A j 053 43 2B + 153 107 6B k 054 44 2C , 154 108 6C l 055 45 2D - 155 109 6D m 056 46 2E . 156 110 6E n 057 47 2F / 157 111 6F o 060 48 30 0 160 112 70 p 061 49 31 1 161 113 71 q 062 50 32 2 162 114 72 r 063 51 33 3 163 115 73 s 064 52 34 4 164 116 74 t 065 53 35 5 165 117 75 u 066 54 36 6 166 118 76 v 067 55 37 7 167 119 77 w 070 56 38 8 170 120 78 x 071 57 39 9 171 121 79 y 072 58 3A : 172 122 7A z 073 59 3B ; 173 123 7B { 074 60 3C < 174 124 7C | 075 61 3D = 175 125 7D } 076 62 3E > 176 126 7E ~ 077 63 3F ? 177 127 7F DEL Tables For convenience, let us give more compact tables in hex and decimal. 2 3 4 5 6 7 30 40 50 60 70 80 90 100 110 120 ------------- --------------------------------- 0: 0 @ P ` p 0: ( 2 < F P Z d n x 1: ! 1 A Q a q 1: ) 3 = G Q [ e o y 2: " 2 B R b r 2: * 4 > H R \ f p z 3: # 3 C S c s 3: ! + 5 ? I S ] g q { 4: $ 4 D T d t 4: " , 6 @ J T ^ h r | 5: % 5 E U e u 5: # - 7 A K U _ i s } 6: & 6 F V f v 6: $ . 8 B L V ` j t ~ 7: ´ 7 G W g w 7: % / 9 C M W a k u DEL 8: ( 8 H X h x 8: & 0 : D N X b l v 9: ) 9 I Y i y 9: ´ 1 ; E O Y c m w A: * : J Z j z B: + ; K [ k { C: , < L \ l | D: - = M ] m } E: . > N ^ n ~ F: / ? O _ o DEL NOTES History An ascii manual page appeared in Version 7 of AT&T UNIX. On older terminals, the underscore code is displayed as a left arrow, called backarrow, the caret is displayed as an up- arrow and the vertical bar has a hole in the middle. Uppercase and lowercase characters differ by just one bit and the ASCII character 2 differs from the double quote by just one bit, too. That made it much easier to encode characters mechanically or with a non-microcontroller-based electronic keyboard and that pairing was found on old teletypes. The ASCII standard was published by the United States of America Standards Institute (USASI) in 1968. SEE ALSO iso_8859-1(7), iso_8859-10(7), iso_8859-13(7), iso_8859-14(7), iso_8859-15(7), iso_8859-16(7), iso_8859-2(7), iso_8859-3(7), iso_8859-4(7), iso_8859-5(7), iso_8859-6(7), iso_8859-7(7), iso_8859-8(7), iso_8859-9(7) COLOPHON This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2009-02-12 ASCII(7)
[root@node101.yinzhengjie.org.cn ~]# file a.txt #不難發現咱們的文件內容爲ASCII編碼 a.txt: ASCII text [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# cat a.txt abc123 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# hexdump a.txt 0000000 6261 3163 3332 000a 0000007 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# hexdump -C a.txt 00000000 61 62 63 31 32 33 0a |abc123.| 00000007 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# file b.txt #因爲我寫的文件包含中文,所以Linux的文件編碼格式默認爲UTF-8。 b.txt: UTF-8 Unicode text [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# cat b.txt 尹正傑 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# hexdump -C b.txt #不難發現通常狀況下,一個漢字對應着3個字節。 00000000 e5 b0 b9 e6 ad a3 e6 9d b0 0a |..........| 0000000a [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# hexdump b.txt 0000000 b0e5 e6b9 a3ad 9de6 0ab0 000000a [root@node101.yinzhengjie.org.cn ~]#
#!/usr/bin/env python #_*_conding:utf-8_*_ #@author :yinzhengjie #blog:http://www.cnblogs.com/yinzhengjie print("尹正傑".encode()) print("尹正傑".encode().hex()) """ 以上代碼輸出結果以下: b'\xe5\xb0\xb9\xe6\xad\xa3\xe6\x9d\xb0' e5b0b9e6ada3e69db0 根據結果進行分析: "尹"的Unicode碼爲:"\xe5\xb0\xb9",須要3個字節存儲,轉換成16進製爲:"e5b0b9",轉換成2進制(得出Unicode編碼)爲:"11100101 10110000 10111001" "正"的Unicode碼爲:"\xe6\xad\xa3",也須要3個字節存儲,轉換16進製爲:"e6ada3",轉換成2進制(得出Unicode編碼)爲:"11100110 10101101 10100011" "傑"的Unicode碼爲:"\xe6\x9d\xb0",仍是須要3個字節存儲,轉換成16進製爲:"e69db0",轉換成2進制(得出Unicode編碼)爲:"11100110 10011101 10110000" """
[root@node101.yinzhengjie.org.cn ~]# iconv -l #Linux查看支持的字符集 The following list contain all the coded character sets known. This does not necessarily mean that all combinations of these names can be used for the FROM and TO command line parameters. One coded character set can be listed with several different names (aliases). 437, 500, 500V1, 850, 851, 852, 855, 856, 857, 860, 861, 862, 863, 864, 865, 866, 866NAV, 869, 874, 904, 1026, 1046, 1047, 8859_1, 8859_2, 8859_3, 8859_4, 8859_5, 8859_6, 8859_7, 8859_8, 8859_9, 10646-1:1993, 10646-1:1993/UCS4, ANSI_X3.4-1968, ANSI_X3.4-1986, ANSI_X3.4, ANSI_X3.110-1983, ANSI_X3.110, ARABIC, ARABIC7, ARMSCII-8, ASCII, ASMO-708, ASMO_449, BALTIC, BIG-5, BIG-FIVE, BIG5-HKSCS, BIG5, BIG5HKSCS, BIGFIVE, BRF, BS_4730, CA, CN-BIG5, CN-GB, CN, CP-AR, CP-GR, CP-HU, CP037, CP038, CP273, CP274, CP275, CP278, CP280, CP281, CP282, CP284, CP285, CP290, CP297, CP367, CP420, CP423, CP424, CP437, CP500, CP737, CP770, CP771, CP772, CP773, CP774, CP775, CP803, CP813, CP819, CP850, CP851, CP852, CP855, CP856, CP857, CP860, CP861, CP862, CP863, CP864, CP865, CP866, CP866NAV, CP868, CP869, CP870, CP871, CP874, CP875, CP880, CP891, CP901, CP902, CP903, CP904, CP905, CP912, CP915, CP916, CP918, CP920, CP921, CP922, CP930, CP932, CP933, CP935, CP936, CP937, CP939, CP949, CP950, CP1004, CP1008, CP1025, CP1026, CP1046, CP1047, CP1070, CP1079, CP1081, CP1084, CP1089, CP1097, CP1112, CP1122, CP1123, CP1124, CP1125, CP1129, CP1130, CP1132, CP1133, CP1137, CP1140, CP1141, CP1142, CP1143, CP1144, CP1145, CP1146, CP1147, CP1148, CP1149, CP1153, CP1154, CP1155, CP1156, CP1157, CP1158, CP1160, CP1161, CP1162, CP1163, CP1164, CP1166, CP1167, CP1250, CP1251, CP1252, CP1253, CP1254, CP1255, CP1256, CP1257, CP1258, CP1282, CP1361, CP1364, CP1371, CP1388, CP1390, CP1399, CP4517, CP4899, CP4909, CP4971, CP5347, CP9030, CP9066, CP9448, CP10007, CP12712, CP16804, CPIBM861, CSA7-1, CSA7-2, CSASCII, CSA_T500-1983, CSA_T500, CSA_Z243.4-1985-1, CSA_Z243.4-1985-2, CSA_Z243.419851, CSA_Z243.419852, CSDECMCS, CSEBCDICATDE, CSEBCDICATDEA, CSEBCDICCAFR, CSEBCDICDKNO, CSEBCDICDKNOA, CSEBCDICES, CSEBCDICESA, CSEBCDICESS, CSEBCDICFISE, CSEBCDICFISEA, CSEBCDICFR, CSEBCDICIT, CSEBCDICPT, CSEBCDICUK, CSEBCDICUS, CSEUCKR, CSEUCPKDFMTJAPANESE, CSGB2312, CSHPROMAN8, CSIBM037, CSIBM038, CSIBM273, CSIBM274, CSIBM275, CSIBM277, CSIBM278, CSIBM280, CSIBM281, CSIBM284, CSIBM285, CSIBM290, CSIBM297, CSIBM420, CSIBM423, CSIBM424, CSIBM500, CSIBM803, CSIBM851, CSIBM855, CSIBM856, CSIBM857, CSIBM860, CSIBM863, CSIBM864, CSIBM865, CSIBM866, CSIBM868, CSIBM869, CSIBM870, CSIBM871, CSIBM880, CSIBM891, CSIBM901, CSIBM902, CSIBM903, CSIBM904, CSIBM905, CSIBM918, CSIBM921, CSIBM922, CSIBM930, CSIBM932, CSIBM933, CSIBM935, CSIBM937, CSIBM939, CSIBM943, CSIBM1008, CSIBM1025, CSIBM1026, CSIBM1097, CSIBM1112, CSIBM1122, CSIBM1123, CSIBM1124, CSIBM1129, CSIBM1130, CSIBM1132, CSIBM1133, CSIBM1137, CSIBM1140, CSIBM1141, CSIBM1142, CSIBM1143, CSIBM1144, CSIBM1145, CSIBM1146, CSIBM1147, CSIBM1148, CSIBM1149, CSIBM1153, CSIBM1154, CSIBM1155, CSIBM1156, CSIBM1157, CSIBM1158, CSIBM1160, CSIBM1161, CSIBM1163, CSIBM1164, CSIBM1166, CSIBM1167, CSIBM1364, CSIBM1371, CSIBM1388, CSIBM1390, CSIBM1399, CSIBM4517, CSIBM4899, CSIBM4909, CSIBM4971, CSIBM5347, CSIBM9030, CSIBM9066, CSIBM9448, CSIBM12712, CSIBM16804, CSIBM11621162, CSISO4UNITEDKINGDOM, CSISO10SWEDISH, CSISO11SWEDISHFORNAMES, CSISO14JISC6220RO, CSISO15ITALIAN, CSISO16PORTUGESE, CSISO17SPANISH, CSISO18GREEK7OLD, CSISO19LATINGREEK, CSISO21GERMAN, CSISO25FRENCH, CSISO27LATINGREEK1, CSISO49INIS, CSISO50INIS8, CSISO51INISCYRILLIC, CSISO58GB1988, CSISO60DANISHNORWEGIAN, CSISO60NORWEGIAN1, CSISO61NORWEGIAN2, CSISO69FRENCH, CSISO84PORTUGUESE2, CSISO85SPANISH2, CSISO86HUNGARIAN, CSISO88GREEK7, CSISO89ASMO449, CSISO90, CSISO92JISC62991984B, CSISO99NAPLPS, CSISO103T618BIT, CSISO111ECMACYRILLIC, CSISO121CANADIAN1, CSISO122CANADIAN2, CSISO139CSN369103, CSISO141JUSIB1002, CSISO143IECP271, CSISO150, CSISO150GREEKCCITT, CSISO151CUBA, CSISO153GOST1976874, CSISO646DANISH, CSISO2022CN, CSISO2022JP, CSISO2022JP2, CSISO2022KR, CSISO2033, CSISO5427CYRILLIC, CSISO5427CYRILLIC1981, CSISO5428GREEK, CSISO10367BOX, CSISOLATIN1, CSISOLATIN2, CSISOLATIN3, CSISOLATIN4, CSISOLATIN5, CSISOLATIN6, CSISOLATINARABIC, CSISOLATINCYRILLIC, CSISOLATINGREEK, CSISOLATINHEBREW, CSKOI8R, CSKSC5636, CSMACINTOSH, CSNATSDANO, CSNATSSEFI, CSN_369103, CSPC8CODEPAGE437, CSPC775BALTIC, CSPC850MULTILINGUAL, CSPC862LATINHEBREW, CSPCP852, CSSHIFTJIS, CSUCS4, CSUNICODE, CSWINDOWS31J, CUBA, CWI-2, CWI, CYRILLIC, DE, DEC-MCS, DEC, DECMCS, DIN_66003, DK, DS2089, DS_2089, E13B, EBCDIC-AT-DE-A, EBCDIC-AT-DE, EBCDIC-BE, EBCDIC-BR, EBCDIC-CA-FR, EBCDIC-CP-AR1, EBCDIC-CP-AR2, EBCDIC-CP-BE, EBCDIC-CP-CA, EBCDIC-CP-CH, EBCDIC-CP-DK, EBCDIC-CP-ES, EBCDIC-CP-FI, EBCDIC-CP-FR, EBCDIC-CP-GB, EBCDIC-CP-GR, EBCDIC-CP-HE, EBCDIC-CP-IS, EBCDIC-CP-IT, EBCDIC-CP-NL, EBCDIC-CP-NO, EBCDIC-CP-ROECE, EBCDIC-CP-SE, EBCDIC-CP-TR, EBCDIC-CP-US, EBCDIC-CP-WT, EBCDIC-CP-YU, EBCDIC-CYRILLIC, EBCDIC-DK-NO-A, EBCDIC-DK-NO, EBCDIC-ES-A, EBCDIC-ES-S, EBCDIC-ES, EBCDIC-FI-SE-A, EBCDIC-FI-SE, EBCDIC-FR, EBCDIC-GREEK, EBCDIC-INT, EBCDIC-INT1, EBCDIC-IS-FRISS, EBCDIC-IT, EBCDIC-JP-E, EBCDIC-JP-KANA, EBCDIC-PT, EBCDIC-UK, EBCDIC-US, EBCDICATDE, EBCDICATDEA, EBCDICCAFR, EBCDICDKNO, EBCDICDKNOA, EBCDICES, EBCDICESA, EBCDICESS, EBCDICFISE, EBCDICFISEA, EBCDICFR, EBCDICISFRISS, EBCDICIT, EBCDICPT, EBCDICUK, EBCDICUS, ECMA-114, ECMA-118, ECMA-128, ECMA-CYRILLIC, ECMACYRILLIC, ELOT_928, ES, ES2, EUC-CN, EUC-JISX0213, EUC-JP-MS, EUC-JP, EUC-KR, EUC-TW, EUCCN, EUCJP-MS, EUCJP-OPEN, EUCJP-WIN, EUCJP, EUCKR, EUCTW, FI, FR, GB, GB2312, GB13000, GB18030, GBK, GB_1988-80, GB_198880, GEORGIAN-ACADEMY, GEORGIAN-PS, GOST_19768-74, GOST_19768, GOST_1976874, GREEK-CCITT, GREEK, GREEK7-OLD, GREEK7, GREEK7OLD, GREEK8, GREEKCCITT, HEBREW, HP-GREEK8, HP-ROMAN8, HP-ROMAN9, HP-THAI8, HP-TURKISH8, HPGREEK8, HPROMAN8, HPROMAN9, HPTHAI8, HPTURKISH8, HU, IBM-803, IBM-856, IBM-901, IBM-902, IBM-921, IBM-922, IBM-930, IBM-932, IBM-933, IBM-935, IBM-937, IBM-939, IBM-943, IBM-1008, IBM-1025, IBM-1046, IBM-1047, IBM-1097, IBM-1112, IBM-1122, IBM-1123, IBM-1124, IBM-1129, IBM-1130, IBM-1132, IBM-1133, IBM-1137, IBM-1140, IBM-1141, IBM-1142, IBM-1143, IBM-1144, IBM-1145, IBM-1146, IBM-1147, IBM-1148, IBM-1149, IBM-1153, IBM-1154, IBM-1155, IBM-1156, IBM-1157, IBM-1158, IBM-1160, IBM-1161, IBM-1162, IBM-1163, IBM-1164, IBM-1166, IBM-1167, IBM-1364, IBM-1371, IBM-1388, IBM-1390, IBM-1399, IBM-4517, IBM-4899, IBM-4909, IBM-4971, IBM-5347, IBM-9030, IBM-9066, IBM-9448, IBM-12712, IBM-16804, IBM037, IBM038, IBM256, IBM273, IBM274, IBM275, IBM277, IBM278, IBM280, IBM281, IBM284, IBM285, IBM290, IBM297, IBM367, IBM420, IBM423, IBM424, IBM437, IBM500, IBM775, IBM803, IBM813, IBM819, IBM848, IBM850, IBM851, IBM852, IBM855, IBM856, IBM857, IBM860, IBM861, IBM862, IBM863, IBM864, IBM865, IBM866, IBM866NAV, IBM868, IBM869, IBM870, IBM871, IBM874, IBM875, IBM880, IBM891, IBM901, IBM902, IBM903, IBM904, IBM905, IBM912, IBM915, IBM916, IBM918, IBM920, IBM921, IBM922, IBM930, IBM932, IBM933, IBM935, IBM937, IBM939, IBM943, IBM1004, IBM1008, IBM1025, IBM1026, IBM1046, IBM1047, IBM1089, IBM1097, IBM1112, IBM1122, IBM1123, IBM1124, IBM1129, IBM1130, IBM1132, IBM1133, IBM1137, IBM1140, IBM1141, IBM1142, IBM1143, IBM1144, IBM1145, IBM1146, IBM1147, IBM1148, IBM1149, IBM1153, IBM1154, IBM1155, IBM1156, IBM1157, IBM1158, IBM1160, IBM1161, IBM1162, IBM1163, IBM1164, IBM1166, IBM1167, IBM1364, IBM1371, IBM1388, IBM1390, IBM1399, IBM4517, IBM4899, IBM4909, IBM4971, IBM5347, IBM9030, IBM9066, IBM9448, IBM12712, IBM16804, IEC_P27-1, IEC_P271, INIS-8, INIS-CYRILLIC, INIS, INIS8, INISCYRILLIC, ISIRI-3342, ISIRI3342, ISO-2022-CN-EXT, ISO-2022-CN, ISO-2022-JP-2, ISO-2022-JP-3, ISO-2022-JP, ISO-2022-KR, ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-9E, ISO-8859-10, ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16, ISO-10646-UCS-2, ISO-10646, ISO-10646/UCS2, ISO-10646/UCS4, ISO-10646/UTF-8, ISO-10646/UTF8, ISO-CELTIC, ISO-IR-4, ISO-IR-6, ISO-IR-8-1, ISO-IR-9-1, ISO-IR-10, ISO-IR-11, ISO-IR-14, ISO-IR-15, ISO-IR-16, ISO-IR-17, ISO-IR-18, ISO-IR-19, ISO-IR-21, ISO-IR-25, ISO-IR-27, ISO-IR-37, ISO-IR-49, ISO-IR-50, ISO-IR-51, ISO-IR-54, ISO-IR-55, ISO-IR-57, ISO-IR-60, ISO-IR-61, ISO-IR-69, ISO-IR-84, ISO-IR-85, ISO-IR-86, ISO-IR-88, ISO-IR-89, ISO-IR-90, ISO-IR-92, ISO-IR-98, ISO-IR-99, ISO-IR-100, ISO-IR-101, ISO-IR-103, ISO-IR-109, ISO-IR-110, ISO-IR-111, ISO-IR-121, ISO-IR-122, ISO-IR-126, ISO-IR-127, ISO-IR-138, ISO-IR-139, ISO-IR-141, ISO-IR-143, ISO-IR-144, ISO-IR-148, ISO-IR-150, ISO-IR-151, ISO-IR-153, ISO-IR-155, ISO-IR-156, ISO-IR-157, ISO-IR-166, ISO-IR-179, ISO-IR-193, ISO-IR-197, ISO-IR-199, ISO-IR-203, ISO-IR-209, ISO-IR-226, ISO/TR_11548-1, ISO646-CA, ISO646-CA2, ISO646-CN, ISO646-CU, ISO646-DE, ISO646-DK, ISO646-ES, ISO646-ES2, ISO646-FI, ISO646-FR, ISO646-FR1, ISO646-GB, ISO646-HU, ISO646-IT, ISO646-JP-OCR-B, ISO646-JP, ISO646-KR, ISO646-NO, ISO646-NO2, ISO646-PT, ISO646-PT2, ISO646-SE, ISO646-SE2, ISO646-US, ISO646-YU, ISO2022CN, ISO2022CNEXT, ISO2022JP, ISO2022JP2, ISO2022KR, ISO6937, ISO8859-1, ISO8859-2, ISO8859-3, ISO8859-4, ISO8859-5, ISO8859-6, ISO8859-7, ISO8859-8, ISO8859-9, ISO8859-9E, ISO8859-10, ISO8859-11, ISO8859-13, ISO8859-14, ISO8859-15, ISO8859-16, ISO11548-1, ISO88591, ISO88592, ISO88593, ISO88594, ISO88595, ISO88596, ISO88597, ISO88598, ISO88599, ISO88599E, ISO885910, ISO885911, ISO885913, ISO885914, ISO885915, ISO885916, ISO_646.IRV:1991, ISO_2033-1983, ISO_2033, ISO_5427-EXT, ISO_5427, ISO_5427:1981, ISO_5427EXT, ISO_5428, ISO_5428:1980, ISO_6937-2, ISO_6937-2:1983, ISO_6937, ISO_6937:1992, ISO_8859-1, ISO_8859-1:1987, ISO_8859-2, ISO_8859-2:1987, ISO_8859-3, ISO_8859-3:1988, ISO_8859-4, ISO_8859-4:1988, ISO_8859-5, ISO_8859-5:1988, ISO_8859-6, ISO_8859-6:1987, ISO_8859-7, ISO_8859-7:1987, ISO_8859-7:2003, ISO_8859-8, ISO_8859-8:1988, ISO_8859-9, ISO_8859-9:1989, ISO_8859-9E, ISO_8859-10, ISO_8859-10:1992, ISO_8859-14, ISO_8859-14:1998, ISO_8859-15, ISO_8859-15:1998, ISO_8859-16, ISO_8859-16:2001, ISO_9036, ISO_10367-BOX, ISO_10367BOX, ISO_11548-1, ISO_69372, IT, JIS_C6220-1969-RO, JIS_C6229-1984-B, JIS_C62201969RO, JIS_C62291984B, JOHAB, JP-OCR-B, JP, JS, JUS_I.B1.002, KOI-7, KOI-8, KOI8-R, KOI8-RU, KOI8-T, KOI8-U, KOI8, KOI8R, KOI8U, KSC5636, L1, L2, L3, L4, L5, L6, L7, L8, L10, LATIN-9, LATIN-GREEK-1, LATIN-GREEK, LATIN1, LATIN2, LATIN3, LATIN4, LATIN5, LATIN6, LATIN7, LATIN8, LATIN9, LATIN10, LATINGREEK, LATINGREEK1, MAC-CENTRALEUROPE, MAC-CYRILLIC, MAC-IS, MAC-SAMI, MAC-UK, MAC, MACCYRILLIC, MACINTOSH, MACIS, MACUK, MACUKRAINIAN, MIK, MS-ANSI, MS-ARAB, MS-CYRL, MS-EE, MS-GREEK, MS-HEBR, MS-MAC-CYRILLIC, MS-TURK, MS932, MS936, MSCP949, MSCP1361, MSMACCYRILLIC, MSZ_7795.3, MS_KANJI, NAPLPS, NATS-DANO, NATS-SEFI, NATSDANO, NATSSEFI, NC_NC0010, NC_NC00-10, NC_NC00-10:81, NF_Z_62-010, NF_Z_62-010_(1973), NF_Z_62-010_1973, NF_Z_62010, NF_Z_62010_1973, NO, NO2, NS_4551-1, NS_4551-2, NS_45511, NS_45512, OS2LATIN1, OSF00010001, OSF00010002, OSF00010003, OSF00010004, OSF00010005, OSF00010006, OSF00010007, OSF00010008, OSF00010009, OSF0001000A, OSF00010020, OSF00010100, OSF00010101, OSF00010102, OSF00010104, OSF00010105, OSF00010106, OSF00030010, OSF0004000A, OSF0005000A, OSF05010001, OSF100201A4, OSF100201A8, OSF100201B5, OSF100201F4, OSF100203B5, OSF1002011C, OSF1002011D, OSF1002035D, OSF1002035E, OSF1002035F, OSF1002036B, OSF1002037B, OSF10010001, OSF10010004, OSF10010006, OSF10020025, OSF10020111, OSF10020115, OSF10020116, OSF10020118, OSF10020122, OSF10020129, OSF10020352, OSF10020354, OSF10020357, OSF10020359, OSF10020360, OSF10020364, OSF10020365, OSF10020366, OSF10020367, OSF10020370, OSF10020387, OSF10020388, OSF10020396, OSF10020402, OSF10020417, PT, PT2, PT154, R8, R9, RK1048, ROMAN8, ROMAN9, RUSCII, SE, SE2, SEN_850200_B, SEN_850200_C, SHIFT-JIS, SHIFT_JIS, SHIFT_JISX0213, SJIS-OPEN, SJIS-WIN, SJIS, SS636127, STRK1048-2002, ST_SEV_358-88, T.61-8BIT, T.61, T.618BIT, TCVN-5712, TCVN, TCVN5712-1, TCVN5712-1:1993, THAI8, TIS-620, TIS620-0, TIS620.2529-1, TIS620.2533-0, TIS620, TS-5881, TSCII, TURKISH8, UCS-2, UCS-2BE, UCS-2LE, UCS-4, UCS-4BE, UCS-4LE, UCS2, UCS4, UHC, UJIS, UK, UNICODE, UNICODEBIG, UNICODELITTLE, US-ASCII, US, UTF-7, UTF-8, UTF-16, UTF-16BE, UTF-16LE, UTF-32, UTF-32BE, UTF-32LE, UTF7, UTF8, UTF16, UTF16BE, UTF16LE, UTF32, UTF32BE, UTF32LE, VISCII, WCHAR_T, WIN-SAMI-2, WINBALTRIM, WINDOWS-31J, WINDOWS-874, WINDOWS-936, WINDOWS-1250, WINDOWS-1251, WINDOWS-1252, WINDOWS-1253, WINDOWS-1254, WINDOWS-1255, WINDOWS-1256, WINDOWS-1257, WINDOWS-1258, WINSAMI2, WS2, YU [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# man 7 charsets CHARSETS(7) Linux Programmer's Manual CHARSETS(7) NAME charsets - character set standards and internationalization DESCRIPTION This manual page gives an overview on different character set standards and how they were used on Linux before Unicode became ubiquitous. Some of this information is still helpful for people working with legacy systems and documents. Standards discussed include such as ASCII, GB 2312, ISO 8859, JIS, KOI8-R, KS, and Unicode. The primary emphasis is on character sets that were actually used by locale character sets, not the myriad others that could be found in data from other systems. The recommended encoding in all settings and locales is UTF-8. ASCII ASCII (American Standard Code For Information Interchange) is the original 7-bit character set, originally designed for American English. Also known as US-ASCII. It is currently described by the ISO 646:1991 IRV (International Reference Ver‐ sion) standard. Various ASCII variants replacing the dollar sign with other currency symbols and replacing punctuation with non-English alphabetic characters to cover German, French, Spanish, and others in 7 bits emerged. All are deprecated; glibc does not support locales whose character sets are not true supersets of ASCII. As Unicode, when using UTF-8, is ASCII-compatible, plain ASCII text still renders properly on modern UTF-8 using systems. ISO 8859 ISO 8859 is a series of 15 8-bit character sets, all of which have ASCII in their low (7-bit) half, invisible control char‐ acters in positions 128 to 159, and 96 fixed-width graphics in positions 160-255. Of these, the most important is ISO 8859-1 ("Latin Alphabet No .1" / Latin-1). It was widely adopted and supported by dif‐ ferent systems, and is gradually being replaced with Unicode. The ISO 8859-1 characters are also the first 256 characters of Unicode. Console support for the other 8859 character sets is available under Linux through user-mode utilities (such as setfont(8)) that modify keyboard bindings and the EGA graphics table and employ the "user mapping" font table in the console driver. Here are brief descriptions of each set: 8859-1 (Latin-1) Latin-1 covers many West European languages such as Albanian, Basque, Danish, English, Faroese, Galician, Icelandic, Irish, Italian, Norwegian, Portuguese, Spanish, and Swedish. The lack of the ligatures Dutch IJ/ij, French œ, and old- style „German「 quotation marks was considered tolerable. 8859-2 (Latin-2) Latin-2 supports many Latin-written Central and East European languages such as Bosnian, Croatian, Czech, German, Hungarian, Polish, Slovak, and Slovene. Replacing Romanian ș/ț with ş/ţ was considered tolerable. 8859-3 (Latin-3) Latin-3 was designed to cover of Esperanto, Maltese, and Turkish, but 8859-9 later superseded it for Turkish. 8859-4 (Latin-4) Latin-4 introduced letters for North European languages such as Estonian, Latvian, and Lithuanian, but was superseded by 8859-10 and 8859-13. 8859-5 Cyrillic letters supporting Bulgarian, Byelorussian, Macedonian, Russian, Serbian, and (almost completely) Ukrainian. It was never widely used, see the discussion of KOI8-R/KOI8-U below. 8859-6 Was created for Arabic. The 8859-6 glyph table is a fixed font of separate letter forms, but a proper display engine should combine these using the proper initial, medial, and final forms. 8859-7 Was created for Modern Greek in 1987, updated in 2003. 8859-8 Supports Modern Hebrew without niqud (punctuation signs). Niqud and full-fledged Biblical Hebrew were outside the scope of this character set. 8859-9 (Latin-5) This is a variant of Latin-1 that replaces Icelandic letters with Turkish ones. 8859-10 (Latin-6) Latin-6 added the Inuit (Greenlandic) and Sami (Lappish) letters that were missing in Latin-4 to cover the entire Nordic area. 8859-11 Supports the Thai alphabet and is nearly identical to the TIS-620 standard. 8859-12 This set does not exist. 8859-13 (Latin-7) Supports the Baltic Rim languages; in particular, it includes Latvian characters not found in Latin-4. 8859-14 (Latin-8) This is the Celtic character set, covering Old Irish, Manx, Gaelic, Welsh, Cornish, and Breton. 8859-15 (Latin-9) Latin-9 is similar to the widely used Latin-1 but replaces some less common symbols with the Euro sign and French and Finnish letters that were missing in Latin-1. 8859-16 (Latin-10) This set covers many Southeast European languages, and most importantly supports Romanian more completely than Latin-2. KOI8-R / KOI8-U KOI8-R is a non-ISO character set popular in Russia before Unicode. The lower half is ASCII; the upper is a Cyrillic char‐ acter set somewhat better designed than ISO 8859-5. KOI8-U, based on KOI8-R, has better support for Ukrainian. Neither of these sets are ISO-2022 compatible, unlike the ISO 8859 series. Console support for KOI8-R is available under Linux through user-mode utilities that modify keyboard bindings and the EGA graphics table, and employ the "user mapping" font table in the console driver. GB 2312 GB 2312 is a mainland Chinese national standard character set used to express simplified Chinese. Just like JIS X 0208, characters are mapped into a 94x94 two-byte matrix used to construct EUC-CN. EUC-CN is the most important encoding for Linux and includes ASCII and GB 2312. Note that EUC-CN is often called as GB, GB 2312, or CN-GB. Big5 Big5 was a popular character set in Taiwan to express traditional Chinese. (Big5 is both a character set and an encoding.) It is a superset of ASCII. Non-ASCII characters are expressed in two bytes. Bytes 0xa1-0xfe are used as leading bytes for two-byte characters. Big5 and its extension were widely used in Taiwan and Hong Kong. It is not ISO 2022 compliant. JIS X 0208 JIS X 0208 is a Japanese national standard character set. Though there are some more Japanese national standard character sets (like JIS X 0201, JIS X 0212, and JIS X 0213), this is the most important one. Characters are mapped into a 94x94 two- byte matrix, whose each byte is in the range 0x21-0x7e. Note that JIS X 0208 is a character set, not an encoding. This means that JIS X 0208 itself is not used for expressing text data. JIS X 0208 is used as a component to construct encodings such as EUC-JP, Shift_JIS, and ISO-2022-JP. EUC-JP is the most important encoding for Linux and includes ASCII and JIS X 0208. In EUC-JP, JIS X 0208 characters are expressed in two bytes, each of which is the JIS X 0208 code plus 0x80. KS X 1001 KS X 1001 is a Korean national standard character set. Just as JIS X 0208, characters are mapped into a 94x94 two-byte matrix. KS X 1001 is used like JIS X 0208, as a component to construct encodings such as EUC-KR, Johab, and ISO-2022-KR. EUC-KR is the most important encoding for Linux and includes ASCII and KS X 1001. KS C 5601 is an older name for KS X 1001. ISO 2022 and ISO 4873 The ISO 2022 and 4873 standards describe a font-control model based on VT100 practice. This model is (partially) supported by the Linux kernel and by xterm(1). Several ISO 2022-based character encodings have been defined, especially for Japanese. There are 4 graphic character sets, called G0, G1, G2, and G3, and one of them is the current character set for codes with xx=B, and ESC ) xx, ESC * xx, ESC + xx are equivalent to ESC - xx, ESC . xx, ESC / xx, respectively. TIS-620 TIS-620 is a Thai national standard character set and a superset of ASCII. In the same fashion as the ISO 8859 series, Thai characters are mapped into 0xa1-0xfe. Unicode Unicode (ISO 10646) is a standard which aims to unambiguously represent every character in every human language. Unicode's structure permits 20.1 bits to encode every character. Since most computers don't include 20.1-bit integers, Unicode is usually encoded as 32-bit integers internally and either a series of 16-bit integers (UTF-16) (needing two 16-bit integers only when encoding certain rare characters) or a series of 8-bit bytes (UTF-8). Linux represents Unicode using the 8-bit Unicode Transformation Format (UTF-8). UTF-8 is a variable length encoding of Uni‐ code. It uses 1 byte to code 7 bits, 2 bytes for 11 bits, 3 bytes for 16 bits, 4 bytes for 21 bits, 5 bytes for 26 bits, 6 bytes for 31 bits. Let 0,1,x stand for a zero, one, or arbitrary bit. A byte 0xxxxxxx stands for the Unicode 00000000 0xxxxxxx which codes the same symbol as the ASCII 0xxxxxxx. Thus, ASCII goes unchanged into UTF-8, and people using only ASCII do not notice any change: not in code, and not in file size. A byte 110xxxxx is the start of a 2-byte code, and 110xxxxx 10yyyyyy is assembled into 00000xxx xxyyyyyy. A byte 1110xxxx is the start of a 3-byte code, and 1110xxxx 10yyyyyy 10zzzzzz is assembled into xxxxyyyy yyzzzzzz. (When UTF-8 is used to code the 31-bit ISO 10646 then this progression continues up to 6-byte codes.) For most texts in ISO 8859 character sets, this means that the characters outside of ASCII are now coded with two bytes. This tends to expand ordinary text files by only one or two percent. For Russian or Greek texts, this expands ordinary text files by 100%, since text in those languages is mostly outside of ASCII. For Japanese users this means that the 16-bit codes. Note that UTF-8 is self-synchronizing: 10xxxxxx is a tail, any other byte is the head of a code. Note that the only way ASCII bytes occur in a UTF-8 stream, is as themselves. In particular, there are no embedded NULs ('\0') or '/'s that form part of some larger code. Since ASCII, and, in particular, NUL and '/', are unchanged, the kernel does not notice that UTF-8 is being used. It does not care at all what the bytes it is handling stand for. Rendering of Unicode data streams is typically handled through "subfont" tables which map a subset of Unicode to glyphs. Internally the kernel uses Unicode to describe the subfont loaded in video RAM. This means that in the Linux console in UTF-8 mode, one can use a character set with 512 different symbols. This is not enough for Japanese, Chinese, and Korean, but it is enough for most other purposes. SEE ALSO iconv(1), ascii(7), iso_8859-1(7), unicode(7), utf-8(7) Linux 2014-08-19 CHARSETS(7)
[root@node101.yinzhengjie.org.cn ~]# localectl list-locales #查看當前操做系統支持的語言 aa_DJ aa_DJ.iso88591 aa_DJ.utf8 aa_ER aa_ER.utf8 aa_ER.utf8@saaho aa_ER@saaho aa_ET aa_ET.utf8 af_ZA af_ZA.iso88591 af_ZA.utf8 am_ET am_ET.utf8 an_ES an_ES.iso885915 an_ES.utf8 ar_AE ar_AE.iso88596 ar_AE.utf8 ar_BH ar_BH.iso88596 ar_BH.utf8 ar_DZ ar_DZ.iso88596 ar_DZ.utf8 ar_EG ar_EG.iso88596 ar_EG.utf8 ar_IN ar_IN.utf8 ar_IQ ar_IQ.iso88596 ar_IQ.utf8 ar_JO ar_JO.iso88596 ar_JO.utf8 ar_KW ar_KW.iso88596 ar_KW.utf8 ar_LB ar_LB.iso88596 ar_LB.utf8 ar_LY ar_LY.iso88596 ar_LY.utf8 ar_MA ar_MA.iso88596 ar_MA.utf8 ar_OM ar_OM.iso88596 ar_OM.utf8 ar_QA ar_QA.iso88596 ar_QA.utf8 ar_SA ar_SA.iso88596 ar_SA.utf8 ar_SD ar_SD.iso88596 ar_SD.utf8 ar_SY ar_SY.iso88596 ar_SY.utf8 ar_TN ar_TN.iso88596 ar_TN.utf8 ar_YE ar_YE.iso88596 ar_YE.utf8 as_IN as_IN.utf8 ast_ES ast_ES.iso885915 ast_ES.utf8 ayc_PE ayc_PE.utf8 az_AZ az_AZ.utf8 be_BY be_BY.cp1251 be_BY.utf8 be_BY.utf8@latin be_BY@latin bem_ZM bem_ZM.utf8 ber_DZ ber_DZ.utf8 ber_MA ber_MA.utf8 bg_BG bg_BG.cp1251 bg_BG.utf8 bho_IN bho_IN.utf8 bn_BD bn_BD.utf8 bn_IN bn_IN.utf8 bo_CN bo_CN.utf8 bo_IN bo_IN.utf8 bokmal br_FR br_FR.iso88591 br_FR.iso885915@euro br_FR.utf8 br_FR@euro brx_IN brx_IN.utf8 bs_BA bs_BA.iso88592 bs_BA.utf8 byn_ER byn_ER.utf8 ca_AD ca_AD.iso885915 ca_AD.utf8 ca_ES ca_ES.iso88591 ca_ES.iso885915@euro ca_ES.utf8 ca_ES@euro ca_FR ca_FR.iso885915 ca_FR.utf8 ca_IT ca_IT.iso885915 ca_IT.utf8 catalan crh_UA crh_UA.utf8 croatian cs_CZ cs_CZ.iso88592 cs_CZ.utf8 csb_PL csb_PL.utf8 cv_RU cv_RU.utf8 cy_GB cy_GB.iso885914 cy_GB.utf8 czech da_DK da_DK.iso88591 da_DK.iso885915 da_DK.utf8 danish dansk de_AT de_AT.iso88591 de_AT.iso885915@euro de_AT.utf8 de_AT@euro de_BE de_BE.iso88591 de_BE.iso885915@euro de_BE.utf8 de_BE@euro de_CH de_CH.iso88591 de_CH.utf8 de_DE de_DE.iso88591 de_DE.iso885915@euro de_DE.utf8 de_DE@euro de_LU de_LU.iso88591 de_LU.iso885915@euro de_LU.utf8 de_LU@euro deutsch doi_IN doi_IN.utf8 dutch dv_MV dv_MV.utf8 dz_BT dz_BT.utf8 eesti el_CY el_CY.iso88597 el_CY.utf8 el_GR el_GR.iso88597 el_GR.iso88597@euro el_GR.utf8 el_GR@euro en_AG en_AG.utf8 en_AU en_AU.iso88591 en_AU.utf8 en_BW en_BW.iso88591 en_BW.utf8 en_CA en_CA.iso88591 en_CA.utf8 en_DK en_DK.iso88591 en_DK.utf8 en_GB en_GB.iso88591 en_GB.iso885915 en_GB.utf8 en_HK en_HK.iso88591 en_HK.utf8 en_IE en_IE.iso88591 en_IE.iso885915@euro en_IE.utf8 en_IE@euro en_IN en_IN.utf8 en_NG en_NG.utf8 en_NZ en_NZ.iso88591 en_NZ.utf8 en_PH en_PH.iso88591 en_PH.utf8 en_SG en_SG.iso88591 en_SG.utf8 en_US en_US.iso88591 en_US.iso885915 en_US.utf8 en_ZA en_ZA.iso88591 en_ZA.utf8 en_ZM en_ZM.utf8 en_ZW en_ZW.iso88591 en_ZW.utf8 es_AR es_AR.iso88591 es_AR.utf8 es_BO es_BO.iso88591 es_BO.utf8 es_CL es_CL.iso88591 es_CL.utf8 es_CO es_CO.iso88591 es_CO.utf8 es_CR es_CR.iso88591 es_CR.utf8 es_CU es_CU.utf8 es_DO es_DO.iso88591 es_DO.utf8 es_EC es_EC.iso88591 es_EC.utf8 es_ES es_ES.iso88591 es_ES.iso885915@euro es_ES.utf8 es_ES@euro es_GT es_GT.iso88591 es_GT.utf8 es_HN es_HN.iso88591 es_HN.utf8 es_MX es_MX.iso88591 es_MX.utf8 es_NI es_NI.iso88591 es_NI.utf8 es_PA es_PA.iso88591 es_PA.utf8 es_PE es_PE.iso88591 es_PE.utf8 es_PR es_PR.iso88591 es_PR.utf8 es_PY es_PY.iso88591 es_PY.utf8 es_SV es_SV.iso88591 es_SV.utf8 es_US es_US.iso88591 es_US.utf8 es_UY es_UY.iso88591 es_UY.utf8 es_VE es_VE.iso88591 es_VE.utf8 estonian et_EE et_EE.iso88591 et_EE.iso885915 et_EE.utf8 eu_ES eu_ES.iso88591 eu_ES.iso885915@euro eu_ES.utf8 eu_ES@euro fa_IR fa_IR.utf8 ff_SN ff_SN.utf8 fi_FI fi_FI.iso88591 fi_FI.iso885915@euro fi_FI.utf8 fi_FI@euro fil_PH fil_PH.utf8 finnish fo_FO fo_FO.iso88591 fo_FO.utf8 fr_BE fr_BE.iso88591 fr_BE.iso885915@euro fr_BE.utf8 fr_BE@euro fr_CA fr_CA.iso88591 fr_CA.utf8 fr_CH fr_CH.iso88591 fr_CH.utf8 fr_FR fr_FR.iso88591 fr_FR.iso885915@euro fr_FR.utf8 fr_FR@euro fr_LU fr_LU.iso88591 fr_LU.iso885915@euro fr_LU.utf8 fr_LU@euro french fur_IT fur_IT.utf8 fy_DE fy_DE.utf8 fy_NL fy_NL.utf8 ga_IE ga_IE.iso88591 ga_IE.iso885915@euro ga_IE.utf8 ga_IE@euro galego galician gd_GB gd_GB.iso885915 gd_GB.utf8 german gez_ER gez_ER.utf8 gez_ER.utf8@abegede gez_ER@abegede gez_ET gez_ET.utf8 gez_ET.utf8@abegede gez_ET@abegede gl_ES gl_ES.iso88591 gl_ES.iso885915@euro gl_ES.utf8 gl_ES@euro greek gu_IN gu_IN.utf8 gv_GB gv_GB.iso88591 gv_GB.utf8 ha_NG ha_NG.utf8 he_IL he_IL.iso88598 he_IL.utf8 hebrew hi_IN hi_IN.utf8 hne_IN hne_IN.utf8 hr_HR hr_HR.iso88592 hr_HR.utf8 hrvatski hsb_DE hsb_DE.iso88592 hsb_DE.utf8 ht_HT ht_HT.utf8 hu_HU hu_HU.iso88592 hu_HU.utf8 hungarian hy_AM hy_AM.armscii8 hy_AM.utf8 ia_FR ia_FR.utf8 icelandic id_ID id_ID.iso88591 id_ID.utf8 ig_NG ig_NG.utf8 ik_CA ik_CA.utf8 is_IS is_IS.iso88591 is_IS.utf8 it_CH it_CH.iso88591 it_CH.utf8 it_IT it_IT.iso88591 it_IT.iso885915@euro it_IT.utf8 it_IT@euro italian iu_CA iu_CA.utf8 iw_IL iw_IL.iso88598 iw_IL.utf8 ja_JP ja_JP.eucjp ja_JP.ujis ja_JP.utf8 japanese japanese.euc ka_GE ka_GE.georgianps ka_GE.utf8 kk_KZ kk_KZ.pt154 kk_KZ.utf8 kl_GL kl_GL.iso88591 kl_GL.utf8 km_KH km_KH.utf8 kn_IN kn_IN.utf8 ko_KR ko_KR.euckr ko_KR.utf8 kok_IN kok_IN.utf8 korean korean.euc ks_IN ks_IN.utf8 ks_IN.utf8@devanagari ks_IN@devanagari ku_TR ku_TR.iso88599 ku_TR.utf8 kw_GB kw_GB.iso88591 kw_GB.utf8 ky_KG ky_KG.utf8 lb_LU lb_LU.utf8 lg_UG lg_UG.iso885910 lg_UG.utf8 li_BE li_BE.utf8 li_NL li_NL.utf8 lij_IT lij_IT.utf8 lithuanian lo_LA lo_LA.utf8 lt_LT lt_LT.iso885913 lt_LT.utf8 lv_LV lv_LV.iso885913 lv_LV.utf8 mag_IN mag_IN.utf8 mai_IN mai_IN.utf8 mg_MG mg_MG.iso885915 mg_MG.utf8 mhr_RU mhr_RU.utf8 mi_NZ mi_NZ.iso885913 mi_NZ.utf8 mk_MK mk_MK.iso88595 mk_MK.utf8 ml_IN ml_IN.utf8 mn_MN mn_MN.utf8 mni_IN mni_IN.utf8 mr_IN mr_IN.utf8 ms_MY ms_MY.iso88591 ms_MY.utf8 mt_MT mt_MT.iso88593 mt_MT.utf8 my_MM my_MM.utf8 nan_TW.utf8@latin nan_TW@latin nb_NO nb_NO.iso88591 nb_NO.utf8 nds_DE nds_DE.utf8 nds_NL nds_NL.utf8 ne_NP ne_NP.utf8 nhn_MX nhn_MX.utf8 niu_NU niu_NU.utf8 niu_NZ niu_NZ.utf8 nl_AW nl_AW.utf8 nl_BE nl_BE.iso88591 nl_BE.iso885915@euro nl_BE.utf8 nl_BE@euro nl_NL nl_NL.iso88591 nl_NL.iso885915@euro nl_NL.utf8 nl_NL@euro nn_NO nn_NO.iso88591 nn_NO.utf8 no_NO no_NO.ISO-8859-1 norwegian nr_ZA nr_ZA.utf8 nso_ZA nso_ZA.utf8 nynorsk oc_FR oc_FR.iso88591 oc_FR.utf8 om_ET om_ET.utf8 om_KE om_KE.iso88591 om_KE.utf8 or_IN or_IN.utf8 os_RU os_RU.utf8 pa_IN pa_IN.utf8 pa_PK pa_PK.utf8 pap_AN pap_AN.utf8 pl_PL pl_PL.iso88592 pl_PL.utf8 polish portuguese ps_AF ps_AF.utf8 pt_BR pt_BR.iso88591 pt_BR.utf8 pt_PT pt_PT.iso88591 pt_PT.iso885915@euro pt_PT.utf8 pt_PT@euro ro_RO ro_RO.iso88592 ro_RO.utf8 romanian ru_RU ru_RU.iso88595 ru_RU.koi8r ru_RU.utf8 ru_UA ru_UA.koi8u ru_UA.utf8 russian rw_RW rw_RW.utf8 sa_IN sa_IN.utf8 sat_IN sat_IN.utf8 sc_IT sc_IT.utf8 sd_IN sd_IN.utf8 sd_IN.utf8@devanagari sd_IN@devanagari se_NO se_NO.utf8 shs_CA shs_CA.utf8 si_LK si_LK.utf8 sid_ET sid_ET.utf8 sk_SK sk_SK.iso88592 sk_SK.utf8 sl_SI sl_SI.iso88592 sl_SI.utf8 slovak slovene slovenian so_DJ so_DJ.iso88591 so_DJ.utf8 so_ET so_ET.utf8 so_KE so_KE.iso88591 so_KE.utf8 so_SO so_SO.iso88591 so_SO.utf8 spanish sq_AL sq_AL.iso88591 sq_AL.utf8 sq_MK sq_MK.utf8 sr_ME sr_ME.utf8 sr_RS sr_RS.utf8 sr_RS.utf8@latin sr_RS@latin ss_ZA ss_ZA.utf8 st_ZA st_ZA.iso88591 st_ZA.utf8 sv_FI sv_FI.iso88591 sv_FI.iso885915@euro sv_FI.utf8 sv_FI@euro sv_SE sv_SE.iso88591 sv_SE.iso885915 sv_SE.utf8 sw_KE sw_KE.utf8 sw_TZ sw_TZ.utf8 swedish szl_PL szl_PL.utf8 ta_IN ta_IN.utf8 ta_LK ta_LK.utf8 te_IN te_IN.utf8 tg_TJ tg_TJ.koi8t tg_TJ.utf8 th_TH th_TH.tis620 th_TH.utf8 thai ti_ER ti_ER.utf8 ti_ET ti_ET.utf8 tig_ER tig_ER.utf8 tk_TM tk_TM.utf8 tl_PH tl_PH.iso88591 tl_PH.utf8 tn_ZA tn_ZA.utf8 tr_CY tr_CY.iso88599 tr_CY.utf8 tr_TR tr_TR.iso88599 tr_TR.utf8 ts_ZA ts_ZA.utf8 tt_RU tt_RU.utf8 tt_RU.utf8@iqtelif tt_RU@iqtelif turkish ug_CN ug_CN.utf8 uk_UA uk_UA.koi8u uk_UA.utf8 unm_US unm_US.utf8 ur_IN ur_IN.utf8 ur_PK ur_PK.utf8 uz_UZ uz_UZ.iso88591 uz_UZ.utf8@cyrillic uz_UZ@cyrillic ve_ZA ve_ZA.utf8 vi_VN vi_VN.utf8 wa_BE wa_BE.iso88591 wa_BE.iso885915@euro wa_BE.utf8 wa_BE@euro wae_CH wae_CH.utf8 wal_ET wal_ET.utf8 wo_SN wo_SN.utf8 xh_ZA xh_ZA.iso88591 xh_ZA.utf8 yi_US yi_US.cp1255 yi_US.utf8 yo_NG yo_NG.utf8 yue_HK yue_HK.utf8 zh_CN zh_CN.gb18030 zh_CN.gb2312 zh_CN.gbk zh_CN.utf8 zh_HK zh_HK.big5hkscs zh_HK.utf8 zh_SG zh_SG.gb2312 zh_SG.gbk zh_SG.utf8 zh_TW zh_TW.big5 zh_TW.euctw zh_TW.utf8 zu_ZA zu_ZA.iso88591 zu_ZA.utf8 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo $LANG #很顯然,咱們安裝操做系統時默認選的就是英文 en_US.UTF-8 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# localectl set-locale LANG=zh_CN.utf8 #咱們將操做系統的語言換成中文的UTF-8,通常狀況下不建議修改!修改後一些提示信息都會邊長中文!包括提示信息之後都爲中文啦,咱們要習慣用英語,最好別改! [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# echo $LANG #修改後咱們發現並無當即生效 en_US.UTF-8 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# logout #推出當前的操做系統,推出當前終端方能生效 Connection closed by foreign host. Disconnected from remote host(node101.yinzhengjie.org.cn) at 12:13:43. Type `help' to learn how to use Xshell prompt. [c:\~]$ Reconnecting in 1 seconds. Press any key to exit local shell. . Host 'node101.yinzhengjie.org.cn' resolved to 172.30.1.101. Connecting to 172.30.1.101:22... Connection established. To escape to local shell, press 'Ctrl+Alt+]'. Last login: Sat Aug 3 20:13:25 2019 from 172.30.1.1 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# echo $LANG #再次查看當前操做系統的界面支持的語言爲發現生效啦~ zh_CN.utf8 [root@node101.yinzhengjie.org.cn ~]#
3>.外部命令查看幫助信息
內部命令: help COMMAND man bash 外部命令: (1) COMMAND --help 或 COMMAND -h (2) 使用手冊(manual) man COMMAND (3) 信息頁 info COMMAND (4) 程序自身的幫助文檔 README INSTALL ChangeLog (5) 程序官方文檔 官方站點:Documentation (6) 發行版的官方文檔 (7) Google
[root@node101.yinzhengjie.org.cn ~]# date --help #查看外部命令date的幫助信息 Usage: date [OPTION]... [+FORMAT] or: date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] Display the current time in the given FORMAT, or set the system date. Mandatory arguments to long options are mandatory for short options too. -d, --date=STRING display time described by STRING, not 'now' -f, --file=DATEFILE like --date once for each line of DATEFILE -I[TIMESPEC], --iso-8601[=TIMESPEC] output date/time in ISO 8601 format. TIMESPEC='date' for date only (the default), 'hours', 'minutes', 'seconds', or 'ns' for date and time to the indicated precision. -r, --reference=FILE display the last modification time of FILE -R, --rfc-2822 output date and time in RFC 2822 format. Example: Mon, 07 Aug 2006 12:34:56 -0600 --rfc-3339=TIMESPEC output date and time in RFC 3339 format. TIMESPEC='date', 'seconds', or 'ns' for date and time to the indicated precision. Date and time components are separated by a single space: 2006-08-07 12:34:56-06:00 -s, --set=STRING set time described by STRING -u, --utc, --universal print or set Coordinated Universal Time (UTC) --help display this help and exit --version output version information and exit FORMAT controls the output. Interpreted sequences are: %% a literal % %a locale's abbreviated weekday name (e.g., Sun) %A locale's full weekday name (e.g., Sunday) %b locale's abbreviated month name (e.g., Jan) %B locale's full month name (e.g., January) %c locale's date and time (e.g., Thu Mar 3 23:05:25 2005) %C century; like %Y, except omit last two digits (e.g., 20) %d day of month (e.g., 01) %D date; same as %m/%d/%y %e day of month, space padded; same as %_d %F full date; same as %Y-%m-%d %g last two digits of year of ISO week number (see %G) %G year of ISO week number (see %V); normally useful only with %V %h same as %b %H hour (00..23) %I hour (01..12) %j day of year (001..366) %k hour, space padded ( 0..23); same as %_H %l hour, space padded ( 1..12); same as %_I %m month (01..12) %M minute (00..59) %n a newline %N nanoseconds (000000000..999999999) %p locale's equivalent of either AM or PM; blank if not known %P like %p, but lower case %r locale's 12-hour clock time (e.g., 11:11:04 PM) %R 24-hour hour and minute; same as %H:%M %s seconds since 1970-01-01 00:00:00 UTC %S second (00..60) %t a tab %T time; same as %H:%M:%S %u day of week (1..7); 1 is Monday %U week number of year, with Sunday as first day of week (00..53) %V ISO week number, with Monday as first day of week (01..53) %w day of week (0..6); 0 is Sunday %W week number of year, with Monday as first day of week (00..53) %x locale's date representation (e.g., 12/31/99) %X locale's time representation (e.g., 23:13:48) %y last two digits of year (00..99) %Y year %z +hhmm numeric time zone (e.g., -0400) %:z +hh:mm numeric time zone (e.g., -04:00) %::z +hh:mm:ss numeric time zone (e.g., -04:00:00) %:::z numeric time zone with : to necessary precision (e.g., -04, +05:30) %Z alphabetic time zone abbreviation (e.g., EDT) By default, date pads numeric fields with zeroes. The following optional flags may follow '%': - (hyphen) do not pad the field _ (underscore) pad with spaces 0 (zero) pad with zeros ^ use upper case if possible # use opposite case if possible After any flags comes an optional field width, as a decimal number; then an optional modifier, which is either E to use the locale's alternate representations if available, or O to use the locale's alternate numeric symbols if available. Examples: Convert seconds since the epoch (1970-01-01 UTC) to a date $ date --date='@2147483647' Show the time on the west coast of the US (use tzselect(1) to find TZ) $ TZ='America/Los_Angeles' date Show the local time for 9AM next Friday on the west coast of the US $ date --date='TZ="America/Los_Angeles" 09:00 next Fri' GNU coreutils online help: <http://www.gnu.org/software/coreutils/> For complete documentation, run: info coreutils 'date invocation' [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# date #查看當前時間,如今爲CST,即東八區 Sat Aug 3 19:53:22 CST 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date -u #查看UTC時間,咱們發現相差了8個小時呢~ Sat Aug 3 11:53:24 UTC 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date -R #若是若是時東八區,咱們能夠看到"-0800"的字樣 Sat, 03 Aug 2019 19:57:47 +0800 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# timedatectl list-timezones #查看世界上全部的時區 Africa/Abidjan Africa/Accra Africa/Addis_Ababa Africa/Algiers Africa/Asmara Africa/Bamako Africa/Bangui Africa/Banjul Africa/Bissau Africa/Blantyre Africa/Brazzaville Africa/Bujumbura Africa/Cairo Africa/Casablanca Africa/Ceuta Africa/Conakry Africa/Dakar Africa/Dar_es_Salaam Africa/Djibouti Africa/Douala Africa/El_Aaiun Africa/Freetown Africa/Gaborone Africa/Harare Africa/Johannesburg Africa/Juba Africa/Kampala Africa/Khartoum Africa/Kigali Africa/Kinshasa Africa/Lagos Africa/Libreville Africa/Lome Africa/Luanda Africa/Lubumbashi Africa/Lusaka Africa/Malabo Africa/Maputo Africa/Maseru Africa/Mbabane Africa/Mogadishu Africa/Monrovia Africa/Nairobi Africa/Ndjamena Africa/Niamey Africa/Nouakchott Africa/Ouagadougou Africa/Porto-Novo Africa/Sao_Tome Africa/Tripoli Africa/Tunis Africa/Windhoek America/Adak America/Anchorage America/Anguilla America/Antigua America/Araguaina America/Argentina/Buenos_Aires America/Argentina/Catamarca America/Argentina/Cordoba America/Argentina/Jujuy America/Argentina/La_Rioja America/Argentina/Mendoza America/Argentina/Rio_Gallegos America/Argentina/Salta America/Argentina/San_Juan America/Argentina/San_Luis America/Argentina/Tucuman America/Argentina/Ushuaia America/Aruba America/Asuncion America/Atikokan America/Bahia America/Bahia_Banderas America/Barbados America/Belem America/Belize America/Blanc-Sablon America/Boa_Vista America/Bogota America/Boise America/Cambridge_Bay America/Campo_Grande America/Cancun America/Caracas America/Cayenne America/Cayman America/Chicago America/Chihuahua America/Costa_Rica America/Creston America/Cuiaba America/Curacao America/Danmarkshavn America/Dawson America/Dawson_Creek America/Denver America/Detroit America/Dominica America/Edmonton America/Eirunepe America/El_Salvador America/Fort_Nelson America/Fortaleza America/Glace_Bay America/Godthab America/Goose_Bay America/Grand_Turk America/Grenada America/Guadeloupe America/Guatemala America/Guayaquil America/Guyana America/Halifax America/Havana America/Hermosillo America/Indiana/Indianapolis America/Indiana/Knox America/Indiana/Marengo America/Indiana/Petersburg America/Indiana/Tell_City America/Indiana/Vevay America/Indiana/Vincennes America/Indiana/Winamac America/Inuvik America/Iqaluit America/Jamaica America/Juneau America/Kentucky/Louisville America/Kentucky/Monticello America/Kralendijk America/La_Paz America/Lima America/Los_Angeles America/Lower_Princes America/Maceio America/Managua America/Manaus America/Marigot America/Martinique America/Matamoros America/Mazatlan America/Menominee America/Merida America/Metlakatla America/Mexico_City America/Miquelon America/Moncton America/Monterrey America/Montevideo America/Montserrat America/Nassau America/New_York America/Nipigon America/Nome America/Noronha America/North_Dakota/Beulah America/North_Dakota/Center America/North_Dakota/New_Salem America/Ojinaga America/Panama America/Pangnirtung America/Paramaribo America/Phoenix America/Port-au-Prince America/Port_of_Spain America/Porto_Velho America/Puerto_Rico America/Punta_Arenas America/Rainy_River America/Rankin_Inlet America/Recife America/Regina America/Resolute America/Rio_Branco America/Santarem America/Santiago America/Santo_Domingo America/Sao_Paulo America/Scoresbysund America/Sitka America/St_Barthelemy America/St_Johns America/St_Kitts America/St_Lucia America/St_Thomas America/St_Vincent America/Swift_Current America/Tegucigalpa America/Thule America/Thunder_Bay America/Tijuana America/Toronto America/Tortola America/Vancouver America/Whitehorse America/Winnipeg America/Yakutat America/Yellowknife Antarctica/Casey Antarctica/Davis Antarctica/DumontDUrville Antarctica/Macquarie Antarctica/Mawson Antarctica/McMurdo Antarctica/Palmer Antarctica/Rothera Antarctica/Syowa Antarctica/Troll Antarctica/Vostok Arctic/Longyearbyen Asia/Aden Asia/Almaty Asia/Amman Asia/Anadyr Asia/Aqtau Asia/Aqtobe Asia/Ashgabat Asia/Atyrau Asia/Baghdad Asia/Bahrain Asia/Baku Asia/Bangkok Asia/Barnaul Asia/Beirut Asia/Bishkek Asia/Brunei Asia/Chita Asia/Choibalsan Asia/Colombo Asia/Damascus Asia/Dhaka Asia/Dili Asia/Dubai Asia/Dushanbe Asia/Famagusta Asia/Gaza Asia/Hebron Asia/Ho_Chi_Minh Asia/Hong_Kong Asia/Hovd Asia/Irkutsk Asia/Jakarta Asia/Jayapura Asia/Jerusalem Asia/Kabul Asia/Kamchatka Asia/Karachi Asia/Kathmandu Asia/Khandyga Asia/Kolkata Asia/Krasnoyarsk Asia/Kuala_Lumpur Asia/Kuching Asia/Kuwait Asia/Macau Asia/Magadan Asia/Makassar Asia/Manila Asia/Muscat Asia/Nicosia Asia/Novokuznetsk Asia/Novosibirsk Asia/Omsk Asia/Oral Asia/Phnom_Penh Asia/Pontianak Asia/Pyongyang Asia/Qatar Asia/Qyzylorda Asia/Riyadh Asia/Sakhalin Asia/Samarkand Asia/Seoul Asia/Shanghai Asia/Singapore Asia/Srednekolymsk Asia/Taipei Asia/Tashkent Asia/Tbilisi Asia/Tehran Asia/Thimphu Asia/Tokyo Asia/Tomsk Asia/Ulaanbaatar Asia/Urumqi Asia/Ust-Nera Asia/Vientiane Asia/Vladivostok Asia/Yakutsk Asia/Yangon Asia/Yekaterinburg Asia/Yerevan Atlantic/Azores Atlantic/Bermuda Atlantic/Canary Atlantic/Cape_Verde Atlantic/Faroe Atlantic/Madeira Atlantic/Reykjavik Atlantic/South_Georgia Atlantic/St_Helena Atlantic/Stanley Australia/Adelaide Australia/Brisbane Australia/Broken_Hill Australia/Currie Australia/Darwin Australia/Eucla Australia/Hobart Australia/Lindeman Australia/Lord_Howe Australia/Melbourne Australia/Perth Australia/Sydney Europe/Amsterdam Europe/Andorra Europe/Astrakhan Europe/Athens Europe/Belgrade Europe/Berlin Europe/Bratislava Europe/Brussels Europe/Bucharest Europe/Budapest Europe/Busingen Europe/Chisinau Europe/Copenhagen Europe/Dublin Europe/Gibraltar Europe/Guernsey Europe/Helsinki Europe/Isle_of_Man Europe/Istanbul Europe/Jersey Europe/Kaliningrad Europe/Kiev Europe/Kirov Europe/Lisbon Europe/Ljubljana Europe/London Europe/Luxembourg Europe/Madrid Europe/Malta Europe/Mariehamn Europe/Minsk Europe/Monaco Europe/Moscow Europe/Oslo Europe/Paris Europe/Podgorica Europe/Prague Europe/Riga Europe/Rome Europe/Samara Europe/San_Marino Europe/Sarajevo Europe/Saratov Europe/Simferopol Europe/Skopje Europe/Sofia Europe/Stockholm Europe/Tallinn Europe/Tirane Europe/Ulyanovsk Europe/Uzhgorod Europe/Vaduz Europe/Vatican Europe/Vienna Europe/Vilnius Europe/Volgograd Europe/Warsaw Europe/Zagreb Europe/Zaporozhye Europe/Zurich Indian/Antananarivo Indian/Chagos Indian/Christmas Indian/Cocos Indian/Comoro Indian/Kerguelen Indian/Mahe Indian/Maldives Indian/Mauritius Indian/Mayotte Indian/Reunion Pacific/Apia Pacific/Auckland Pacific/Bougainville Pacific/Chatham Pacific/Chuuk Pacific/Easter Pacific/Efate Pacific/Enderbury Pacific/Fakaofo Pacific/Fiji Pacific/Funafuti Pacific/Galapagos Pacific/Gambier Pacific/Guadalcanal Pacific/Guam Pacific/Honolulu Pacific/Kiritimati Pacific/Kosrae Pacific/Kwajalein Pacific/Majuro Pacific/Marquesas Pacific/Midway Pacific/Nauru Pacific/Niue Pacific/Norfolk Pacific/Noumea Pacific/Pago_Pago Pacific/Palau Pacific/Pitcairn Pacific/Pohnpei Pacific/Port_Moresby Pacific/Rarotonga Pacific/Saipan Pacific/Tahiti Pacific/Tarawa Pacific/Tongatapu Pacific/Wake Pacific/Wallis UTC [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# date Sat Aug 3 19:59:31 CST 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date -R Sat, 03 Aug 2019 19:59:33 +0800 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# timedatectl set-timezone America/New_York #修改時區爲美國的紐約 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date -R Sat, 03 Aug 2019 07:59:44 -0400 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date Sat Aug 3 07:59:47 EDT 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date -u #查看UTC時間 Sat Aug 3 12:00:21 UTC 2019 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /etc/localtime #咱們能夠查看當前時間指定的時區文件爲美國紐約時間文件 lrwxrwxrwx. 1 root root 38 Aug 3 07:59 /etc/localtime -> ../usr/share/zoneinfo/America/New_York [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date -R Sat, 03 Aug 2019 08:02:19 -0400 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date Sat Aug 3 08:02:23 EDT 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# timedatectl set-timezone Asia/Shanghai #咱們把時區修改成亞洲的上海 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date Sat Aug 3 20:02:32 CST 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date -R Sat, 03 Aug 2019 20:02:36 +0800 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /etc/localtime #修改時區成功後,咱們發現該文件指定的時區文件也發生了變化喲~ lrwxrwxrwx. 1 root root 35 Aug 3 20:02 /etc/localtime -> ../usr/share/zoneinfo/Asia/Shanghai [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# date #查看操做系統當前時間 Sat Aug 3 20:18:28 CST 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date +%Y-%m-%d #自定義時間的打印格式 2019-08-03 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date +%F #打印年月日,其實咱們上面自定義的打印格式,咱們直接輸入默認就已經定義了這種格式 2019-08-03 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date +%T #打印時分秒, 20:19:23 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date "+%F %T" #若是使用多個參數的話,須要使用雙引號將其括起來。 2019-08-03 20:19:42 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date +%F_%T #固然,除了上面使用雙引號將其括起來,還可使用下劃線來鏈接兩個參數,達到了自定義時間的輸出格式的目的 2019-08-03_20:20:02 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date 080312242019.30 #修改操做系統的時間 Sat Aug 3 12:24:30 CST 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date #不難發現時間被修改啦~ Sat Aug 3 12:24:32 CST 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date +%s #查看是時間戳,從1970-1-1 00:00:00到目前位置通過的秒數。 1567485345 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# date #查當前時間 Sun Aug 4 12:28:04 CST 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date -d "yesterday" #查看昨天的時間 Sat Aug 3 12:28:16 CST 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date -d "yesterday" +%F #查看昨天的時間並按照格式化輸出 2019-08-03 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date -d "tomorrow" +%F #查看明天的時間 2019-08-05 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date -d "-20 days" +%F #查看20天前的時間 2019-07-15 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date -d "30 days" +%F #查看30天后的時間,這個只是查看時間而已,並無修改喲~ 2019-09-03 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date #查看當前時間,很顯然時間並無發生變化 Sun Aug 4 12:31:09 CST 2019 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# date Sun Aug 4 12:32:25 CST 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date -s "30 days" +%F #咱們發現它不只僅能查看時間,並且還把時間給改啦! 2019-09-03 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date #很顯然,時間被該了一個月(30天)啦! Tue Sep 3 12:32:32 CST 2019 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# clock #主板時間,咱們也能夠稱之爲硬件時間,這個時間通常和操做系統時間相同,可是當主板的電池被扣了或者沒電的話,可能每次開機時間都不會準確啦! Sat 03 Aug 2019 08:29:43 PM CST -0.131667 seconds [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date #查看操做系統的時間,發現主板上的時間和操做系統的時間不一致! Sat Aug 3 12:30:44 CST 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# clock -s #將硬件時間同步到操做系統時間,這樣就保證了操做系統的時間與硬件時間一致! [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date #很顯然,操做系統時間和主板時間相同啦! Sat Aug 3 20:33:38 CST 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# clock #2個時間時時一致性的,只不過操做系統用的是24小時計時法,而硬件使用的是12小時計時法 Sat 03 Aug 2019 08:33:55 PM CST -0.942629 seconds [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# date #查看系統的時間 Sun Aug 4 12:25:07 CST 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# clock #查看主板的時間 Sat 03 Aug 2019 08:38:39 PM CST -0.708404 seconds [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# clock -w #咱們將操做系統的時間同步到主板上來,這樣就保證了硬件的時間和操做系統時間一致! [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# clock #再次查看硬件時間,發現硬件時間被修改啦,和操做系統時間一致啦~ Sun 04 Aug 2019 12:25:28 PM CST -0.958213 seconds [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cal --help Usage: cal [options] [[[day] month] year] Options: -1, --one show only current month (default) -3, --three show previous, current and next month -s, --sunday Sunday as first day of week -m, --monday Monday as first day of week -j, --julian output Julian dates -y, --year show whole current year -V, --version display version information and exit -h, --help display this help text and exit [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cal 2020 #查看某一年的幫助信息 2020 January February March Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 1 1 2 3 4 5 6 7 5 6 7 8 9 10 11 2 3 4 5 6 7 8 8 9 10 11 12 13 14 12 13 14 15 16 17 18 9 10 11 12 13 14 15 15 16 17 18 19 20 21 19 20 21 22 23 24 25 16 17 18 19 20 21 22 22 23 24 25 26 27 28 26 27 28 29 30 31 23 24 25 26 27 28 29 29 30 31 April May June Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 1 2 1 2 3 4 5 6 5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13 12 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20 19 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27 26 27 28 29 30 24 25 26 27 28 29 30 28 29 30 31 July August September Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 1 1 2 3 4 5 5 6 7 8 9 10 11 2 3 4 5 6 7 8 6 7 8 9 10 11 12 12 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 19 19 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 26 26 27 28 29 30 31 23 24 25 26 27 28 29 27 28 29 30 30 31 October November December Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 4 5 6 7 8 9 10 8 9 10 11 12 13 14 6 7 8 9 10 11 12 11 12 13 14 15 16 17 15 16 17 18 19 20 21 13 14 15 16 17 18 19 18 19 20 21 22 23 24 22 23 24 25 26 27 28 20 21 22 23 24 25 26 25 26 27 28 29 30 31 29 30 27 28 29 30 31 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cal 8 2020 #查看某年某月的日曆 August 2020 Su Mo Tu We Th Fr Sa 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 31 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cal -y #顯示日曆 2019 January February March Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 5 1 2 1 2 6 7 8 9 10 11 12 3 4 5 6 7 8 9 3 4 5 6 7 8 9 13 14 15 16 17 18 19 10 11 12 13 14 15 16 10 11 12 13 14 15 16 20 21 22 23 24 25 26 17 18 19 20 21 22 23 17 18 19 20 21 22 23 27 28 29 30 31 24 25 26 27 28 24 25 26 27 28 29 30 31 April May June Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 1 2 3 4 1 7 8 9 10 11 12 13 5 6 7 8 9 10 11 2 3 4 5 6 7 8 14 15 16 17 18 19 20 12 13 14 15 16 17 18 9 10 11 12 13 14 15 21 22 23 24 25 26 27 19 20 21 22 23 24 25 16 17 18 19 20 21 22 28 29 30 26 27 28 29 30 31 23 24 25 26 27 28 29 30 July August September Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 1 2 3 1 2 3 4 5 6 7 7 8 9 10 11 12 13 4 5 6 7 8 9 10 8 9 10 11 12 13 14 14 15 16 17 18 19 20 11 12 13 14 15 16 17 15 16 17 18 19 20 21 21 22 23 24 25 26 27 18 19 20 21 22 23 24 22 23 24 25 26 27 28 28 29 30 31 25 26 27 28 29 30 31 29 30 October November December Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 5 1 2 1 2 3 4 5 6 7 6 7 8 9 10 11 12 3 4 5 6 7 8 9 8 9 10 11 12 13 14 13 14 15 16 17 18 19 10 11 12 13 14 15 16 15 16 17 18 19 20 21 20 21 22 23 24 25 26 17 18 19 20 21 22 23 22 23 24 25 26 27 28 27 28 29 30 31 24 25 26 27 28 29 30 29 30 31 [root@node101.yinzhengjie.org.cn ~]#
4>.man幫助信息
一.man命令概述 (1)提供命令幫助的文件 (2)手冊頁存放在/usr/share/man (3)幾乎每一個命令都有man的「頁面」 (4)man頁面分組爲不一樣的「章節」 (5)統稱爲Linux手冊 (6)man命令的配置文件: /etc/man.config | man_db.conf MANPATH /PATH/TO/SOMEWHERE: 指明man文件搜索位置 (7)man -M /PATH/TO/SOMEWHERE COMMAND: 到指定位置下搜索 COMMAND命令的手冊頁並顯示 (8)中文man需安裝包man-pages-zh-CN 二.man 章節(對於用戶來說,咱們只須要關係1-9這幾個章節便可,其餘章節可忽略,基本上我們運維也用不上呀~) (1)用戶命令 (2)系統調用 (3)C庫調用 (4)設備文件及特殊文件 (5)配置文件格式 (6)遊戲 (7)雜項 (8)管理類的命令 (9)Linux 內核API 三.man 幫助段落說明 (1)NAME 名稱及簡要說明 (2)SYNOPSIS 用法格式說明 [] : 可選內容 <> : 必選內容 a|b : 二選一 { } : 分組 ...: : 同一內容可出現屢次 (3)DESCRIPTION 詳細說明 (4)OPTIONS 選項說明 (5)EXAMPLES 示例 (6)FILES 相關文件 (7)AUTHOR 做者 (8)COPYRIGHT 版本信息 (9)REPORTING BUGS bug信息 (10)SEE ALSO 其它幫助參考 四.man 幫助 (1)查看man手冊頁 man [章節] keyword (2)列出全部幫助 man –a keyword (3)搜索man手冊 man -k keyword 列出全部匹配的頁面 使用 whatis 數據庫 (4)至關於whatis man –f keyword (5)打印man幫助文件的路徑 man –w [章節] keyword 五.man命令的操做方法:使用less命令實現 space, ^v, ^f, ^F: 向文件尾翻屏 b, ^b: 向文件首部翻屏 d, ^d: 向文件尾部翻半屏 u, ^u: 向文件首部翻半屏 RETURN, ^N, e, ^E or j or ^J: 向文件尾部翻一行 y or ^Y or ^P or k or ^K:向文件首部翻一行 q: 退出 #:跳轉至第#行 1G: 回到文件首部 G:翻至文件尾部 六.man搜索 /KEYWORD: 以KEYWORD指定的字符串爲關鍵字,從當前位置向文件尾部搜索;不區分字符大小寫; n: 下一個 N:上一個 ?KEYWORD: 以KEYWORD指定的字符串爲關鍵字,從當前位置向文件首部搜索;不區 分字符大小寫; n: 跟搜索命令同方向,下一個 N:跟搜索命令反方向,上一個
[root@node101.yinzhengjie.org.cn ~]# man date #查看date命令的man幫助信息 DATE(1) User Commands DATE(1) NAME date - print or set the system date and time SYNOPSIS date [OPTION]... [+FORMAT] date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] DESCRIPTION Display the current time in the given FORMAT, or set the system date. Mandatory arguments to long options are mandatory for short options too. -d, --date=STRING display time described by STRING, not 'now' -f, --file=DATEFILE like --date once for each line of DATEFILE -I[TIMESPEC], --iso-8601[=TIMESPEC] output date/time in ISO 8601 format. TIMESPEC='date' for date only (the default), 'hours', 'minutes', 'seconds', or 'ns' for date and time to the indicated precision. -r, --reference=FILE display the last modification time of FILE -R, --rfc-2822 output date and time in RFC 2822 format. Example: Mon, 07 Aug 2006 12:34:56 -0600 --rfc-3339=TIMESPEC output date and time in RFC 3339 format. TIMESPEC='date', 'seconds', or 'ns' for date and time to the indicated pre‐ cision. Date and time components are separated by a single space: 2006-08-07 12:34:56-06:00 -s, --set=STRING set time described by STRING -u, --utc, --universal print or set Coordinated Universal Time (UTC) --help display this help and exit --version output version information and exit FORMAT controls the output. Interpreted sequences are: %% a literal % %a locale's abbreviated weekday name (e.g., Sun) %A locale's full weekday name (e.g., Sunday) %b locale's abbreviated month name (e.g., Jan) %B locale's full month name (e.g., January) %c locale's date and time (e.g., Thu Mar 3 23:05:25 2005) %C century; like %Y, except omit last two digits (e.g., 20) %d day of month (e.g., 01) %D date; same as %m/%d/%y %e day of month, space padded; same as %_d %F full date; same as %Y-%m-%d %g last two digits of year of ISO week number (see %G) %G year of ISO week number (see %V); normally useful only with %V %h same as %b %H hour (00..23) %I hour (01..12) %j day of year (001..366) %k hour, space padded ( 0..23); same as %_H %l hour, space padded ( 1..12); same as %_I %m month (01..12) %M minute (00..59) %n a newline %N nanoseconds (000000000..999999999) %p locale's equivalent of either AM or PM; blank if not known %P like %p, but lower case %r locale's 12-hour clock time (e.g., 11:11:04 PM) %R 24-hour hour and minute; same as %H:%M %s seconds since 1970-01-01 00:00:00 UTC %S second (00..60) %t a tab %T time; same as %H:%M:%S %u day of week (1..7); 1 is Monday %U week number of year, with Sunday as first day of week (00..53) %V ISO week number, with Monday as first day of week (01..53) %w day of week (0..6); 0 is Sunday %W week number of year, with Monday as first day of week (00..53) %x locale's date representation (e.g., 12/31/99) %X locale's time representation (e.g., 23:13:48) %y last two digits of year (00..99) %Y year %z +hhmm numeric time zone (e.g., -0400) %:z +hh:mm numeric time zone (e.g., -04:00) %::z +hh:mm:ss numeric time zone (e.g., -04:00:00) %:::z numeric time zone with : to necessary precision (e.g., -04, +05:30) %Z alphabetic time zone abbreviation (e.g., EDT) By default, date pads numeric fields with zeroes. The following optional flags may follow '%': - (hyphen) do not pad the field _ (underscore) pad with spaces 0 (zero) pad with zeros ^ use upper case if possible # use opposite case if possible After any flags comes an optional field width, as a decimal number; then an optional modifier, which is either E to use the locale's alternate representations if available, or O to use the locale's alternate numeric symbols if available. ENVIRONMENT TZ Specifies the timezone, unless overridden by command line parameters. If neither is specified, the setting from /etc/localtime is used. EXAMPLES Convert seconds since the epoch (1970-01-01 UTC) to a date $ date --date='@2147483647' Show the time on the west coast of the US (use tzselect(1) to find TZ) $ TZ='America/Los_Angeles' date Show the local time for 9AM next Friday on the west coast of the US $ date --date='TZ="America/Los_Angeles" 09:00 next Fri' GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report date translation bugs to <http://translationpro‐ ject.org/team/> DATE STRING The --date=STRING is a mostly free format human readable date string such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or even "next Thursday". A date string may contain items indicating calendar date, time of day, time zone, day of week, relative time, relative date, and numbers. An empty string indicates the beginning of the day. The date string format is more complex than is easily documented here but is fully described in the info documentation. AUTHOR Written by David MacKenzie. COPYRIGHT GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report date translation bugs to <http://translationpro‐ ject.org/team/> DATE STRING The --date=STRING is a mostly free format human readable date string such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or even "next Thursday". A date string may contain items indicating calendar date, time of day, time zone, day of week, relative time, relative date, and numbers. An empty string indicates the beginning of the day. The date string format is more complex than is easily documented here but is fully described in the info documentation. AUTHOR Written by David MacKenzie. COPYRIGHT Copyright © 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO The full documentation for date is maintained as a Texinfo manual. If the info and date programs are properly installed at your site, the command info coreutils 'date invocation' should give you access to the complete manual. GNU coreutils 8.22 October 2018 DATE(1)
[root@node101.yinzhengjie.org.cn ~]# whatis passwd #查詢passwd相關的幫助信息 passwd (5) - password file #咱們看到了括號裏面有一個數字5,說明要查看它的man幫助章節信息應該爲配置文件格式的,而whatis也說他是一個密碼文件。 passwd (1) - update user's authentication tokens #咱們能夠看到括號裏面有一個數字1,說明查看它的man幫助章節信息應該爲用戶命令,而whatis也說他是用來更新用戶認證的令牌的。 sslpasswd (1ssl) - compute password hashes #這個1ssl適合加密相關的章節,這裏的幫助信息基本上是和開發相關的,我們運維通常不用關心它。 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# man 5 passwd #咱們查看配置文件 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# man 1 passwd [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# whereis passwd passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man5/passwd.5.gz /usr/share/man/man1/passwd.1.gz [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# man -w passwd /usr/share/man/man1/passwd.1.gz [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# man -w 5 passwd #查看命令的幫助文件所做路徑 /usr/share/man/man5/passwd.5.gz [root@node101.yinzhengjie.org.cn ~]#
5>.info(不經常使用)
一.info概述 (1)man經常使用於命令參考 ,GNU工具info適合通用文檔參考 (2)沒有參數,列出全部的頁面 (3)info 頁面的結構就像一個網站 (4)每一頁分爲「節點」 (5)連接節點以前 * (6)info [ 命令 ] 二.導航info頁 (1)方向鍵,PgUp,PgDn 導航 (2)Tab鍵 移動到下一個連接 (3)d 顯示主題目錄 (4)Home 顯示主題首部 (5)Enter進入 選定連接 (6)n/p/u/l 進入下/前/上一層/最後一個連接 (7)s 文字 文本搜索 (8)q 退出 info
[root@node101.yinzhengjie.org.cn ~]# info File: dir Node: Top This is the top of the INFO tree This (the Directory node) gives a menu of major topics. Typing "q" exits, "?" lists all Info commands, "d" returns here, "h" gives a primer for first-timers, "mEmacs<Return>" visits the Emacs topic, etc. In Emacs, you can click mouse button 2 on a menu item or cross reference to select it. * Menu: Archiving * Cpio: (cpio). Copy-in-copy-out archiver to tape or disk. * Tar: (tar). Making tape (or disk) archives. Basics * Common options: (coreutils)Common options. * Coreutils: (coreutils). Core GNU (file, text, shell) utilities. * Date input formats: (coreutils)Date input formats. * File permissions: (coreutils)File permissions. Access modes. * File permissions: (coreutils)File permissions. Access modes. * Finding files: (find). Operating on files matching certain criteria. * ed: (ed). The GNU Line Editor. Compression * Gzip: (gzip). General (de)compression of files (lzw). Editors * nano: (nano). Small and friendly text editor. Emacs * IDN Library: (libidn)Emacs API. Emacs API for IDN functions. Encryption * Nettle: (nettle). A low-level cryptographic library. GNU C library functions and macros * __fbufsize: (libc)Controlling Buffering. * __flbf: (libc)Controlling Buffering. * __fpending: (libc)Controlling Buffering. .......
6>.經過本地文檔獲取幫助
System->help(centos6 圖像界面)
Applications -> documentation->help(centos7 圖像界面) 提供的官方使用指南和發行註記
/usr/share/doc目錄
多數安裝了的軟件包的子目錄,包括了這些軟件的相關原理說明
常見文檔:README INSTALL CHANGES
不適合其它地方的文檔的位置
配置文件範例
HTML/PDF/PS 格式的文檔
受權書詳情
[root@node101.yinzhengjie.org.cn ~]# ll /usr/share/doc/ |wc -l #安裝軟件成功後,在這個目錄下有對應的文檔 1023 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /usr/share/doc/ | grep bc-1.06.95 #舉個栗子,咱們在操做系統默認安裝了bc工具,所以咱們能夠進入bc的幫助文檔目錄 drwxr-xr-x. 3 root root 108 Aug 1 21:59 bc-1.06.95 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /usr/share/doc/bc-1.06.95/ #這裏就是bc文檔的相關信息 total 64 -rw-r--r--. 1 root root 241 Jun 15 2006 AUTHORS -rw-r--r--. 1 root root 17997 May 27 2005 COPYING -rw-r--r--. 1 root root 26545 May 27 2005 COPYING.LIB drwxr-xr-x. 2 root root 65 Aug 1 21:59 Examples -rw-r--r--. 1 root root 1335 Apr 21 2006 FAQ -rw-r--r--. 1 root root 2627 Apr 21 2006 NEWS -rw-r--r--. 1 root root 3522 Jul 14 2000 README [root@node101.yinzhengjie.org.cn ~]#
7>.經過在線文檔獲取幫助
第三方應用官方文檔 http://httpd.apache.org http://www.nginx.org https://mariadb.com/kb/en https://dev.mysql.com/doc/ http://tomcat.apache.org http://www.python.org 經過發行版官方的文檔光盤或網站能夠得到 安裝指南、部署指南、虛擬化指南等 紅帽知識庫和官方在線文檔 http://kbase.redhat.com http://www.redhat.com/docs http://access.redhat.com https://help.ubuntu.com/lts/serverguide/index.html 網站和搜索 http://tldp.org #Linux的學習網站 http://www.slideshare.net #存放各類幻燈片的網站,能夠直接把別人寫好的文檔下載下來來而後本身用 http://www.google.com 搜索技巧: Openstack filetype:pdf #只搜索PDF文件且包含openstack字樣的連接 rhca site:redhat.com/docs #只在紅帽官方網站的docs目錄下搜索rhca字樣的連接
8>.小試牛刀
經過幫助信息,在本機字符終端登陸時,除顯示原有信息外,再顯示當前登陸終端號,主機名和當前時間 1>.第一步查看"issue"的用法 whatis issue man issue 2>.找到符合題意的變量並寫入到issue的配置文件中便可 [root@node101.yinzhengjie.org.cn ~]# cat /etc/issue terminal is \l hostname is \n time is \t welcome to https://www.cnblogs.com/yinzhengjie/ !!! \S Kernel \r on an \m [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# whatis issue issue (5) - prelogin message and identification file [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# man issue #查看issue的相關幫助信息 ISSUE(5) Linux Programmer's Manual ISSUE(5) NAME issue - prelogin message and identification file DESCRIPTION The file /etc/issue is a text file which contains a message or system identification to be printed before the login prompt. It may contain various @char and \char sequences, if supported by the getty-type program employed on the system. FILES /etc/issue SEE ALSO motd(5), agetty(8), mingetty(8) #這裏讓咱們參考這3個文件,咱們能夠參考一下agetty命令的幫助信息 COLOPHON This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 1993-07-24 ISSUE(5)
[root@node101.yinzhengjie.org.cn ~]# whatis agetty agetty (8) - alternative Linux getty [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# man 8 agetty AGETTY(8) System Administration AGETTY(8) NAME agetty - alternative Linux getty SYNOPSIS agetty [options] port [baud_rate...] [term] DESCRIPTION agetty opens a tty port, prompts for a login name and invokes the /bin/login command. It is normally invoked by init(8). agetty has several non-standard features that are useful for hard-wired and for dial-in lines: · Adapts the tty settings to parity bits and to erase, kill, end-of-line and uppercase characters when it reads a login name. The program can handle 7-bit characters with even, odd, none or space parity, and 8-bit characters with no parity. The following special characters are recognized: Control-U (kill); DEL and back space (erase); carriage return and line feed (end of line). See also --erase-chars and --kill-chars options. · Optionally deduces the baud rate from the CONNECT messages produced by Hayes(tm)-compatible modems. · Optionally does not hang up when it is given an already opened line (useful for call-back applications). · Optionally does not display the contents of the /etc/issue file. · Optionally displays an alternative issue file instead of /etc/issue. · Optionally does not ask for a login name. · Optionally invokes a non-standard login program instead of /bin/login. · Optionally turns on hard-ware flow control · Optionally forces the line to be local with no need for carrier detect. This program does not use the /etc/gettydefs (System V) or /etc/gettytab (SunOS 4) files. ARGUMENTS port A path name relative to the /dev directory. If a "-" is specified, agetty assumes that its standard input is already connected to a tty port and that a connection to a remote user has already been established. Under System V, a "-" port argument should be preceded by a "--". baud_rate,... A comma-separated list of one or more baud rates. Each time agetty receives a BREAK character it advances through the list, which is treated as if it were circular. Baud rates should be specified in descending order, so that the null character (Ctrl-@) can also be used for baud rate switching. This argument is optional and unnecessary for virtual terminals. The default for serial terminals is '9600'. term The value to be used for the TERM environment variable. This overrides whatever init(8) may have set, and is inher‐ ited by login and the shell. The default is 'vt100', or 'linux' for Linux on virtual terminal, or 'hurd' for GNU Hurd on virtual terminal. OPTIONS -8, --8bits Assume that the tty is 8-bit clean, hence disable parity detection. -a, --autologin username Log the specified user automatically in without asking for a login name and password. The -f username option is added to the /bin/login command line by default. The --login-options option changes this default behaviour and then only \u is replaced by the username and no other option is added to the login command line. Note that --autologin may affect the way how agetty initializes the serial line, because on auto-login agetty does not read from the line and it has no opportunity optimize the line setting. -c, --noreset Don't reset terminal cflags (control modes). See termios(3) for more details. -E, --remote If -H fakehost option is given then -r fakehost options is added to the /bin/login command line. -f, --issue-file issue_file Display the contents of issue_file instead of /etc/issue. This allows custom messages to be displayed on different terminals. The -i option will override this option. -h, --flow-control Enable hardware (RTS/CTS) flow control. It is left up to the application to disable software (XON/XOFF) flow protocol where appropriate. -H, --host login_host Write the specified login_host into the utmp file. (Normally, no login host is given, since agetty is used for local hardwired connections and consoles. However, this option can be useful for identifying terminal concentrators and the like. -i, --noissue Do not display the contents of /etc/issue (or other) before writing the login prompt. Terminals or communications hardware may become confused when receiving lots of text at the wrong baud rate; dial-up scripts may fail if the login prompt is preceded by too much text. -I, --init-string initstring Set an initial string to be sent to the tty or modem before sending anything else. This may be used to initialize a modem. Non printable characters may be sent by writing their octal code preceded by a backslash (\). For example to send a linefeed character (ASCII 10, octal 012) write \012. -l, --login-program login_program Invoke the specified login_program instead of /bin/login. This allows the use of a non-standard login program (for example, one that asks for a dial-up password or that uses a different password file). -L, --local-line Force the line to be a local line with no need for carrier detect. This can be useful when you have a locally attached terminal where the serial line does not set the carrier detect signal. -m, --extract-baud Try to extract the baud rate the CONNECT status message produced by Hayes(tm)-compatible modems. These status mes‐ sages are of the form: "<junk><speed><junk>". agetty assumes that the modem emits its status message at the same speed as specified with (the first) baud_rate value on the command line. Since the -m feature may fail on heavily-loaded systems, you still should enable BREAK processing by enumerating all expected baud rates on the command line. -n, --skip-login Do not prompt the user for a login name. This can be used in connection with -l option to invoke a non-standard login process such as a BBS system. Note that with the -n option, agetty gets no input from user who logs in and therefore won't be able to figure out parity, character size, and newline processing of the connection. It defaults to space parity, 7 bit characters, and ASCII CR (13) end-of-line character. Beware that the program that agetty starts (usu‐ ally /bin/login) is run as root. -o, --login-options "login_options" Options that are passed to the login program. \u is replaced by the login name. The default /bin/login command line is "/bin/login -- <username>". Please read the SECURITY NOTICE below if you want to use this. -p, --login-pause Wait for any key before dropping to the login prompt. Can be combined with --autologin to save memory by lazily spawning shells. -r, --chroot "directory" Change root to the specified directory. -R, --hangup Do call vhangup() for a virtually hangup of the specified terminal. -s, --keep-baud Try to keep the existing baud rate. The baud rates from the command line are used when agetty receives a BREAK char‐ acter. -t, --timeout timeout Terminate if no user name could be read within timeout seconds. This option should probably not be used with hard- wired lines. -U, --detect-case Turn on support for detecting an uppercase only terminal. This setting will detect a login name containing only cap‐ itals as indicating an uppercase only terminal and turn on some upper to lower case conversions. Note that this has no support for any unicode characters. -w, --wait-cr Wait for the user or the modem to send a carriage-return or a linefeed character before sending the /etc/issue (or other) file and the login prompt. Very useful in connection with the -I option. --noclear Do not clear the screen before prompting for the login name (the screen is normally cleared). Do not print hints about Num, Caps and Scroll Locks. --nonewline Do not print a newline before writing out /etc/issue. --nohostname By default the hostname will be printed. With this option enabled, no hostname at all will be shown. --long-hostname By default the hostname is only printed until the first dot. With this option enabled, the fully qualified hostname by gethostname() or (if not found) by getaddrinfo() is shown. --erase-chars string This option specifies additional characters that should be interpreted as a backspace ("ignore the previous charac‐ ter") when the user types the login name. The default additional ´erase´ has been ´#´, but since util-linux 2.23 no additional erase characters are enabled by default. --kill-chars string This option specifies additional characters that should be interpreted as a kill ("ignore all previous characters") when the user types the login name. The default additional ´kill´ has been ´@´, but since util-linux 2.23 no addi ‐ tional kill characters are enabled by default. --version Display version information and exit. --help Display help text and exit. EXAMPLES This section shows examples for the process field of an entry in the /etc/inittab file. You'll have to prepend appropriate values for the other fields. See inittab(5) for more details. For a hard-wired line or a console tty: /sbin/agetty 9600 ttyS1 For a directly connected terminal without proper carriage detect wiring: (try this if your terminal just sleeps instead of giving you a password: prompt.) /sbin/agetty -L 9600 ttyS1 vt100 For a old style dial-in line with a 9600/2400/1200 baud modem: /sbin/agetty -mt60 ttyS1 9600,2400,1200 For a Hayes modem with a fixed 115200 bps interface to the machine: (the example init string turns off modem echo and result codes, makes modem/computer DCD track modem/modem DCD, makes a DTR drop cause a dis-connection and turn on auto-answer after 1 ring.) /sbin/agetty -w -I 'ATE0Q1&D2&C1S0=1\015' 115200 ttyS1 SECURITY NOTICE If you use the --login-program and --login-options options, be aware that a malicious user may try to enter lognames with embedded options, which then get passed to the used login program. Agetty does check for a leading "-" and makes sure the logname gets passed as one parameter (so embedded spaces will not create yet another parameter), but depending on how the login binary parses the command line that might not be sufficient. Check that the used login program can not be abused this way. Some programs use "--" to indicate that the rest of the commandline should not be interpreted as options. Use this feature if available by passing "--" before the username gets passed by \u. ISSUE ESCAPES The issue-file (/etc/issue or the file set with the -f option) may contain certain escape codes to display the system name, date and time etc. All escape codes consist of a backslash (\) immediately followed by one of the letters explained below. 4 or 4{interface} Insert the IPv4 address of the machine hostname or IPv4 address the configured network interface if the interface argument is specified (e.g. \4{eth0}). 6 or 6{interface} Insert the IPv6 address of the machine hostname or IPv6 address the configured network interface if the interface argument is specified (e.g. \6{eth0}} b Insert the baudrate of the current line. d Insert the current date. s Insert the system name, the name of the operating system. Same as `uname -s'. See also \S escape code. S or S{VARIABLE} Insert the VARIABLE data from /etc/os-release. If the VARIABLE argument is not specified then use PRETTY_NAME from the file or the system name (see \s). This escape code allows to keep /etc/issue distribution and release indepen‐ dent. Note that \S{ANSI_COLOR} is converted to the real terminal escape sequence. l Insert the name of the current tty line. m Insert the architecture identifier of the machine. Same as `uname -m'. n Insert the nodename of the machine, also known as the hostname. Same as `uname -n'. o Insert the NIS domainname of the machine. Same as `hostname -d'. O Insert the DNS domainname of the machine. r Insert the release number of the OS. Same as `uname -r'. t Insert the current time. u Insert the number of current users logged in. U Insert the string "1 user" or "<n> users" where <n> is the number of current users logged in. v Insert the version of the OS, eg. the build-date etc. Example: On my system, the following /etc/issue file: This is \n.\o (\s \m \r) \t displays as This is thingol.orcan.dk (Linux i386 1.1.9) 18:29:30 FILES /var/run/utmp the system status file. /etc/issue printed before the login prompt. /etc/os-release operating system identification data. /dev/console problem reports (if syslog(3) is not used). /etc/inittab init(8) configuration file for SysV-style init daemon. BUGS The baud-rate detection feature (the -m option) requires that agetty be scheduled soon enough after completion of a dial-in BUGS The baud-rate detection feature (the -m option) requires that agetty be scheduled soon enough after completion of a dial-in call (within 30 ms with modems that talk at 2400 baud). For robustness, always use the -m option in combination with a mul‐ tiple baud rate command-line argument, so that BREAK processing is enabled. The text in the /etc/issue file (or other) and the login prompt are always output with 7-bit characters and space parity. The baud-rate detection feature (the -m option) requires that the modem emits its status message after raising the DCD line. DIAGNOSTICS Depending on how the program was configured, all diagnostics are written to the console device or reported via the syslog(3) facility. Error messages are produced if the port argument does not specify a terminal device; if there is no utmp entry for the current process (System V only); and so on. AUTHORS Werner Fink ⟨werner@suse.de⟩ Karel Zak ⟨kzak@redhat.com⟩ The original agetty for serial terminals was written by W.Z. Venema <wietse@wzv.win.tue.nl> and ported to Linux by Peter Orbaek <poe@daimi.aau.dk>. AVAILABILITY The agetty command is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/. util-linux May 2011 AGETTY(8)
經過查看幫助信息,在今天18:30自動關機,並提示用戶 1>.查看關機相關命令 [root@node101.yinzhengjie.org.cn ~]# whatis shutdown shutdown (8) - Halt, power-off or reboot the machine #咱們看到章節8比較符合題意,所以咱們須要經過man幫助查看關於shutdown的幫助信息 shutdown (2) - shut down part of a full-duplex connection shutdown (3p) - shut down socket send and receive operations [root@node101.yinzhengjie.org.cn ~]# 2>.查找到相關用法後,咱們能夠直接執行命令: [root@node101.yinzhengjie.org.cn ~]# shutdown 18:00 "System will poweroff" #設置成功後會有相關的提示信息喲~ Shutdown scheduled for Tue 2019-09-03 18:00:00 CST, use 'shutdown -c' to cancel. [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# man -k shutdown #搜索man幫助關於shutdown相關詞彙 dracut-shutdown.service (8) - unpack the initramfs to /run/initramfs posix_trace_create (3p) - trace stream initialization, flush, and shutdown from a process (TRACING) posix_trace_create_withlog (3p) - trace stream initialization, flush, and shutdown from a process (TRACING) posix_trace_flush (3p) - trace stream initialization, flush, and shutdown from a process (TRACING) posix_trace_shutdown (3p) - trace stream initialization, flush, and shutdown from a process (TRACING) shutdown (2) - shut down part of a full-duplex connection shutdown (3p) - shut down socket send and receive operations shutdown (8) - Halt, power-off or reboot the machine systemd-backlight (8) - Load and save the display backlight brightness at boot and shutdown systemd-backlight@.service (8) - Load and save the display backlight brightness at boot and shutdown systemd-halt.service (8) - System shutdown logic systemd-kexec.service (8) - System shutdown logic systemd-poweroff.service (8) - System shutdown logic systemd-random-seed (8) - Load and save the system random seed at boot and shutdown systemd-random-seed.service (8) - Load and save the system random seed at boot and shutdown systemd-reboot.service (8) - System shutdown logic systemd-rfkill (8) - Load and save the RF kill switch state at boot and shutdown systemd-rfkill@.service (8) - Load and save the RF kill switch state at boot and shutdown systemd-shutdown (8) - System shutdown logic systemd-shutdownd (8) - Scheduled shutdown service systemd-shutdownd.service (8) - Scheduled shutdown service systemd-shutdownd.socket (8) - Scheduled shutdown service systemd-update-utmp (8) - Write audit and utmp updates at bootup, runlevel changes and shutdown systemd-update-utmp-runlevel.service (8) - Write audit and utmp updates at bootup, runlevel changes and shutdown systemd-update-utmp.service (8) - Write audit and utmp updates at bootup, runlevel changes and shutdown systemd-user-sessions (8) - Permit user logins after boot, prohibit user logins at shutdown systemd-user-sessions.service (8) - Permit user logins after boot, prohibit user logins at shutdown [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# man 8 shutdown #查看shutdown關機命令相關的幫助信息 SHUTDOWN(8) shutdown SHUTDOWN(8) NAME shutdown - Halt, power-off or reboot the machine SYNOPSIS shutdown [OPTIONS...] [TIME] [WALL...] DESCRIPTION shutdown may be used to halt, power-off or reboot the machine. The first argument may be a time string (which is usually "now"). Optionally, this may be followed by a wall message to be sent to all logged-in users before going down. The time string may either be in the format "hh:mm" for hour/minutes specifying the time to execute the shutdown at, specified in 24h clock format. Alternatively it may be in the syntax "+m" referring to the specified number of minutes m from now. "now" is an alias for "+0", i.e. for triggering an immediate shutdown. If no time argument is specified, "+1" is implied. Note that to specify a wall message you must specify a time argument, too. If the time argument is used, 5 minutes before the system goes down the /run/nologin file is created to ensure that further logins shall not be allowed. OPTIONS The following options are understood: --help Print a short help text and exit. -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". EXIT STATUS On success, 0 is returned, a non-zero failure code otherwise. SEE ALSO systemd(1), systemctl(1), halt(8), wall(1) systemd 219 SHUTDOWN(8)
[root@node101.yinzhengjie.org.cn ~]# date Tue Sep 3 14:37:39 CST 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# shutdown 18:00 "System will poweroff" #咱們在今天18:00關閉服務器,咱們在引號裏面能夠設置關閉服務的提示信息 Shutdown scheduled for Tue 2019-09-03 18:00:00 CST, use 'shutdown -c' to cancel. #這裏告訴咱們可使用"shutdown -c"指令去終止服務器關機 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date 090317552019 #我這裏手動修改了服務器時間,爲了就是讓他早點觸發關機的提示 Tue Sep 3 17:55:00 CST 2019 Broadcast message from root@node101.yinzhengjie.org.cn (Tue 2019-09-03 17:55:00 CST): System will poweroff #看到這一行了沒有?這的提示就是咱們剛剛在引號裏面寫的提示信息呢~ The system is going down for power-off at Tue 2019-09-03 18:00:00 CST! [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date Tue Sep 3 17:55:02 CST 2019 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# shutdown -c #這裏就是終止服務器關機 Broadcast message from root@node101.yinzhengjie.org.cn (Tue 2019-09-03 17:55:12 CST): The system shutdown has been cancelled at Tue 2019-09-03 17:56:12 CST! #這裏有相應的提示,說服務器關機指令被終止了,還打印出來了終止關機的時間 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
九.命令行擴展、被括起來的集合
1>.單引號和雙引號
[root@node101.yinzhengjie.org.cn ~]# echo '$PATH' #很顯然,單引號的話會原樣輸出字符,不會對單引號裏面的變量進行解釋 $PATH [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# echo "$PATH" #雙引號的話,就能夠解釋變量 /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [root@node101.yinzhengjie.org.cn ~]#
2>.命令行擴展:$( ) 或 ``
[root@node101.yinzhengjie.org.cn ~]# echo "This system's name is $(hostname) " #很顯然,"$()"也能夠解釋變量 This system's name is node101.yinzhengjie.org.cn [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# echo "i am `whoami` " #除了上面的「$()"能夠解釋變量,咱們還可使用反引號來解釋變量 i am root [root@node101.yinzhengjie.org.cn ~]#
3>.括號擴展:{ }
[root@node101.yinzhengjie.org.cn ~]# echo file{1,3,5} #可使用枚舉的方法 file1 file3 file5 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# echo file{1..5} #取變量1到變量5之間的整數 file1 file2 file3 file4 file5 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# echo file{1..10..2} #取變量1到變量10之間的整數並指定步長爲2 file1 file3 file5 file7 file9 [root@node101.yinzhengjie.org.cn ~]#
十.歷史命令
1>.命令行歷史
一.命令行歷史概述 (1)保存你輸入的命令歷史。能夠用它來重複執行命令 (2)登陸shell時,會讀取命令歷史文件中記錄下的命令~/.bash_history (3)登陸進shell後新執行的命令只會記錄在緩存中;這些命令會用戶退出時「追加」至命令歷史文件中 二.命令行歷史的使用方法 (1)重複前一個命令,有4種方法 重複前一個命令使用上方向鍵,並回車執行 按 !! 並回車執行 輸入 !-1 並回車執行 按 Ctrl+p 並回車執行 (2)!:0 執行前一條命令(去除參數) (3)Ctrl + n 顯示當前歷史中的下一條命令,但不執行 (4)Ctrl + j 執行當前命令 (5)!n 執行history命令輸出對應序號n的命令 (6)!-n 執行history歷史中倒數第n個命令 (7)!string 重複前一個以「string」開頭的命令 (8)!?string 重複前一個包含string的命令 (9)!string:p 僅打印命令歷史,而不執行 (10)!$:p 打印輸出 !$ (上一條命令的最後一個參數)的內容 (11)!*:p 打印輸出 !*(上一條命令的全部參數)的內容 (12)^string 刪除上一條命令中的第一個string (13)^string1^string2 將上一條命令中的第一個string1替換爲string2 (14)!:gs/string1/string2 將上一條命令中全部的string1都替換爲 string2 (15)使用up(向上)和down(向下)鍵來上下瀏覽從前輸入的命令 (16)ctrl-r來在命令歷史中搜索命令 (reverse-i-search)`’: (17)Ctrl+g:從歷史搜索模式退出 (18)要從新調用前一個命令中最後一個參數 !$ 表示 Esc, .(點擊Esc鍵後鬆開,而後點擊 . 鍵) Alt+ .(按住Alt鍵的同時點擊 . 鍵)
2>.調用歷史參數
(1)command !^ 利用上一個命令的第一個參數作cmd的參數 (2)command !$ 利用上一個命令的最後一個參數作cmd的參數 (3)command !* 利用上一個命令的所有參數作cmd的參數 (4)command !:n 利用上一個命令的第n個參數作cmd的參數 (5)command !n:^ 調用第n條命令的第一個參數 (6)command !n:$ 調用第n條命令的最後一個參數 (7)command !n:m 調用第n條命令的第m個參數 (8)command !n:* 調用第n條命令的全部參數 (9)command !string:^ 從命令歷史中搜索以 string 開頭的命令,並獲取它的第一 個參數 (10)command !string:$ 從命令歷史中搜索以 string 開頭的命令,並獲取它的最後一 個參數 (11)(command !string:n 從命令歷史中搜索以 string 開頭的命令,並獲取它的第n 個參數 (12)command !string:* 從命令歷史中搜索以 string 開頭的命令,並獲取它的全部 參數
3>.命令history
history [-c] [-d offset] [n]
history -anrw [filename]
history -ps arg [arg...]
-c: 清空命令歷史
-d offset: 刪除歷史中指定的第offset個命令
n: 顯示最近的n條歷史
-a: 追加本次會話新執行的命令歷史列表至歷史文件
-r: 讀歷史文件附加到歷史列表
-w: 保存歷史列表到指定的歷史文件
-n: 讀歷史文件中未讀過的行到歷史列表
-p: 展開歷史參數成多行,但不存在歷史列表中
-s: 展開歷史參數成一行,附加在歷史列表後
[root@node101.yinzhengjie.org.cn ~]# history #查看當前命令行中執行的歷史命令。 1 vi /etc/bashrc #第一個參數爲保存歷史命令的編號,第二個參數爲執行的歷史命令 2 cat /etc/bashrc 3 cat /etc/hostname 4 reboot 5 vi /etc/hostname 6 vi /etc/sysconfig/network-scripts/ifcfg-ens33 7 /etc/init.d/network restart 8 ifconfig 9 ping www.baidu.com 10 ifconfig n 11 ifconfig 12 lscpu 13 free 14 free -h 15 lsblk 16 ifconfig 17 cat /etc/redhat-release 18 yum -y install lsb_release 19 yum search ifconfig 20 yum search lsb_release 21 lsblk 22 yum search lsb_release 23 lsb_release 24 yum install -y redhat-lsb 25 lsb_release -a 26 cat /etc/redhat-release 27 lsb_release -a 28 cat /etc/os-release 29 uname -re 30 uname -r 31 uname -a 32 hostname 33 ttp 34 tty 35 who 36 whoami 37 who am i 38 whoami 39 free 40 init 3 41 free 42 \ 43 runlevel 44 init 5 45 runlevel 46 reboot 47 cat /etc/redhat-release 48 ping www.baidu.com 49 runlevel 50 gedit 51 gedit /etc/gdm/custom.conf 52 cat /etc/gdm/custom.conf 53 cat /etc/redhat-release 54 ping www.baidu.com 55 echo ${SHELL} \ 56 echo ${SHELL} 57 cat /etc/shells 58 cat /etc/hostname 59 tty 60 echo $PS1 61 PS1="\[\e[1;5;41;33m\][\u@\h \W]\\$\[\e[0m\]" 62 PS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 63 cat /etc/profile.d/env.sh 64 type ls 65 type echo 66 enable 67 ls -l /bin/bash 68 hostname 69 type hostname 70 type echo 71 type uname 72 type type 73 hash 74 hash -l 75 echo $PATH 76 hash 77 hash -l 78 hash -p 79 hash -p /usr/bin/hostname 80 hash 81 hash -r 82 hash 83 uname -r 84 hash 85 echo $PATH 86 mv /usr/bin/uname /usr/local/bin/ 87 uname -r 88 hash -d uname 89 hash 90 uname -r 91 hash 92 help enable 93 help 94 which -a | --skip-alias 95 which hostname 96 which echo 97 whereis echo 98 which hostname 99 whereis hostname 100 which hostname 101 whereis hostname 102 which echo 103 whereis echo 104 alias 105 date -R 106 init 0 107 echo $PS1 108 PS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 109 PS1=" \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 110 PS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 111 PS1="[\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 112 PS1="\[[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 113 PS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 114 PS1=" \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 115 PS1="[\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 116 PS1="\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 117 PS1="[\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 118 PS1="[\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 119 PS1="[ \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 120 PS1="[\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 121 PS1="[\t \[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$" 122 PS1="[\t \[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\#" 123 PS1="[\t \[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$" 124 PS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 125 PS1="\[\e[1;32m\][\[\e[0m\][\t \[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$ " 126 PS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 127 PS1="\[\e[1;32m\][\[\e[0m\][\t \[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$ " 128 PS1="\\e[1;32m\][\[\e[0m\][\t \[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$" 129 1="\\e[1;32m\][\[\e[0m\][\t \[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$" 130 PS1="[\t \[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\#" 131 PS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 132 1="\\e[1;32m\][\[\e[0m\][\t \[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$" 133 PS1="\\e[1;32m\][\[\e[0m\][\t \[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$" 134 1="\\e[1;32m\][\[\e[0m\][\t \[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$" 135 1="\\e[1;32m\][\[\e[0m\][\t \[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$""\ [\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 136 "\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 137 cd 138 "\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 139 PS1="[\t \[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$" 140 [\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$ 141 PS1=[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$ 142 PS1="[\t \[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$" 143 PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$" 144 ifconfig 145 cat /etc/profile.d/ 146 ll /etc/profile.d/ 147 vi /etc/profile.d/env.sh 148 echo $PATH 149 echo $PS1 150 PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$" 151 PS1="[\t \[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$" 152 who 153 whoami 154 PS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 155 PS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\H\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 156 PS1="\[\e[1;32m\][\[\e[0m\]\t [\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$ " 157 PS1="\[\e[1;32m\][\[\e[0m\]\t [\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\$" 158 PS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\H\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" 159 cd 160 vi /etc/profile.d/env.sh 161 cat /etc/profile.d/env.sh 162 ifconfig 163 cat /etc/redhat-release 164 ping www.baidu.com 165 alias 166 date -r 167 date -R 168 ifconfig 169 cd /etc/sysconfig/network-scripts/ 170 cd 171 alias cdnet='cd /etc/sysconfig/network-scripts/' 172 alias 173 cdnet 174 pwd 175 cd 176 ifconfig 177 ping www.baidu.com 178 ifconfig 179 cat /etc/redhat-release 180 cd 181 rm -rf /etc/profile.d/env.sh 182 ifconfig 183 cat /etc/redhat-release 184 ping www.baidu] 185 ifconfig 186 ping www.baidu.com 187 cat /etc/redhat-release 188 ifconfig 189 \ 190 alias 191 alias cdnet='cd /etc/sysconfig/network-scripts/' 192 alias 193 unalias cdnet 194 alias 195 alias cdnet='cd /etc/sysconfig/network-scripts/' 196 alias cdnet 197 type cdnet 198 ifconfig 199 enable 200 hostname 201 alias enable=hostname 202 enable 203 cdd 204 sdsa 205 type hostname 206 bc 207 python 208 ifconfig 209 cat /etc/os-release 210 ifconfig 211 enable 212 alias 213 cat /etc/redhat-release 214 cat /etc/os-release 215 alias 216 pwd 217 cat .bashrc 218 vi .bashrc 219 cat .bashrc 220 vi .bashrc 221 alias 222 source .bashrc 223 alias 224 cat .bashrc 225 vi /etc/bashrc 226 tail -2 /etc/bashrc 227 . /etc/bashrc 228 alias 229 alias -a 230 alias 231 unalias -a 232 alias 233 hostname 234 alias cd=hostname 235 cd 236 'cd' /etc/sysconfig/network-scripts/ 237 \cd /etc/ 238 unalias cd 239 cd /root/ 240 alias 241 which ls 242 which --skip-aliase ls 243 alias 244 which ls 245 which --skip-alias ls 246 \which ls 247 'which' ls 248 id -o 249 id -u 250 ls -g 251 id -u 252 free -h 253 uname -r 254 id -u 255 free -h 256 fdisk -l 257 free 258 man free 259 free --si 260 man free 261 free --peta 262 free --peta --si 263 free --si 264 ls --all 265 which --skip-alias pwd 266 a 267 ip a 268 ps aux 269 file anaconda-ks.cfg 270 rz -E 271 file anaconda-ks.cfg 272 ls 273 file anaconda-ks.cfg 274 file Notepad++.lnk 275 file anaconda-ks.cfg 276 id -u yinzhengjie 277 alias ls 278 man alias 279 alias -l 280 file anaconda-ks.cfg 281 id -u yinzhengjie 282 bc 283 free 284 free ;hostname 285 free ;hostname;ifconfig ens33 286 free ;hostname;ifconfig 287 hostname 288 cat /etc/sysconfig/network-scripts/ ifcf-ens33 289 hostname 290 hostname 291 whatis 292 whatis ls 293 whatis RM 294 whatis rm 295 whatis uname 296 whatis cal 297 mandb 298 whatis date 299 type data 300 type date 301 type echo 302 help 303 help echo 304 date 305 help date 306 echo --help 307 type echo 308 type date 309 help date 310 help echo 311 type help 312 echo \a 313 echo "\a" 314 315 echo "\a" 316 echo -e "\a" 317 echo -e \a 318 echo -e "\a" 319 echo "abc\bxyz" 320 echo -e "abc\bxyz" 321 echo -e "abc" 322 echo -e "abc\c" 323 echo -e "abc\n123\nxyz" 324 echo -e "abc\f123" 325 echo -e "abcd\f123" 326 echo -e "abcd\f123\fxyz" 327 echo -e "abc\t123" 328 echo -e "abc\t123\txyz" 329 echo -e "yinzhengjie\t2019\tjason" 330 echo -e "yinzhengjie\t2019\tjason\n123\t456\789" 331 echo -e "yinzhengjie\t2019\tjason\n123\t456\t789" 332 echo -e "yinzhengjie\t2019\tjason" 333 echo -e "yinzhengjie\v2019\vjason" 334 echo -e "yinzhengjie\v2019\vjason" | wc -l 335 echo -e "yinzhengjie\f2019\fjason" 336 echo -e "yinzhengjie\f2019\fjason" | wc -l 337 echo -e "yinzhengjie\e2019\fjason" | wc -l 338 echo -e "yinzhengjie\e2019\fjason" 339 echo -e "yinzhengjie\f2019\fjason" 340 echo -e "yinzhengjie\f2019\ejason" 341 echo -e "yinzhengjie\f2019\fjason" 342 echo -e "yinzhengjie\f2019\rjason" 343 echo -e "yinzhengjie\r2019\rjason" 344 echo -e "yinzhengjie\r2019" 345 echo -e "\\" 346 man assci 347 man ascii 348 kk 349 ll 350 ll Videos/ 351 rm -rf * 352 ll 353 ifconfig 354 nano a.txt 355 vi a.txtm 356 ll 357 rm -rf a.txtm 358 ll 359 vi a.txt 360 cat a.txt 361 hexdump a.txt 362 cat a.txt 363 hexdump a.txt 364 file a.txt 365 cat a.txt 366 hexdump a.txt 367 hexdump -C a.txt 368 vi b.txt 369 cat b.txt 370 file b.txt 371 cat b.txt 372 hexdump -C b.txt 373 hexdump b.txt 374 echo $LANG 375 man 7 charset 376 man 7 charsets 377 iconv -l 378 echo -e "\0101" 379 echo -e "\0102" 380 echo -e "\0103" 381 \ 382 echo -e "\x103" 383 echo -e "\x41" 384 echo -e "\x42" 385 echo -e "\x43" 386 date 387 date --help 388 help date 389 date 390 date -u 391 date -R 392 timedatectl 393 timedatectl list-timezones 394 date -R 395 date 396 date -R 397 timedatectl set-timezone America/New_York 398 date -R 399 date 400 date -u 401 ll /etc/localtime 402 date -R 403 date 404 timedatectl set-timezone Asia/Shanghai 405 date 406 date -R 407 ll /etc/localtime 408 loca 409 echo $Lang 410 echo $LANG 411 localectl 412 localectl list-locales 413 414 ll 415 echo $LANG 416 localectl set-locale LANG= zh_CN.utf8 417 echo $LANG 418 localectl set-locale LANG=zh_CN.utf8 419 echo $LANG 420 localectl set-locale en_US.UTF-8 421 localectl set-locale LANG=en_US.UTF-8 422 echo $LANG 423 date %F 424 date %Y 425 date +%Y 426 date +%H 427 date +%d 428 date 429 date +%Y-%m-%d 430 date +%F 431 date +%T 432 date "+%F %T" 433 date +%F_%T 434 date --help 435 ] [MMDDhhmm[[CC]YY][.ss]] 436 date 080312243030.30 437 date 438 date --help 439 [MMDDhhmm[[CC]YY][.ss]] 440 date 441 date 080312242019.30 442 date 443 ifconfig 444 ping www.baidu.com 445 clock 446 date 447 clock 448 clock -s 449 date 450 clock 451 date 452 clock 453 date 080412242019.30 454 date 455 clock 456 date 457 clock 458 clock -w 459 date 460 clock 461 date 462 date -d "yesterday" 463 date -d "yesterday" +%F 464 date -d "tomorrow" +%F 465 date -d "-20 days" +%F 466 date -d "30 days" +%F 467 date 468 date -s "30 days" +%F 469 date 470 date +%s 471 ll -h 472 ll -s 473 ll -h 474 ls 475 cal --help 476 cal 2020 477 cal 8 2020 478 cal -y 479 cal 480 date 481 ifconfig 482 cat /etc/redhat-release 483 ping www.baidu.co 484 ping www.baidu.com 485 whereis da 486 whereis date 487 cat /usr/share/man/man1/date.1.gz 488 XshellXshellXshellXshellXshellXshellXshellXshellXshellXshellXshellXshellXshellXshell 489 man date 490 ] 491 man date 492 which passwd 493 whereis passwd 494 whatis passwd 495 man 5 passwd 496 man 1 passwd 497 man passwd 498 man 5 passwd 499 man man 500 \ 501 whatis man 502 man 7 man 503 vi /etc/motd 504 cat /etc/motd 505 vi /etc/motd 506 cat /etc/motd 507 ping 127.0.0.1 508 509 vi /etc/issue 510 cat /etc/issue 511 whereis passwd 512 man -w passwd 513 man -w 5 passwd 514 man ls 515 uname -n 516 cat /etc/os-release 517 whatis issue 518 man issue 519 whatis agetty 520 man 8 agetty 521 vi /etc/issue 522 cat /etc/issue 523 man -k shutdown 524 whatis shutdown 525 526 l 527 man 8 shutdown 528 date 529 shutdown 18:00 "System will poweroff" 530 date 090317552019 531 date 532 shutdown -c 533 534 info ls 535 info 536 info pwd 537 info 538 ll /usr/share/doc/ 539 540 ll /usr/share/doc/ |wc -l 541 ll /usr/share/doc/ | grep lrzsz 542 ll /usr/share/doc/ | grep bc 543 ll /usr/share/doc/ | grep bc-1.06.95 544 l 545 ll /usr/share/doc/ |wc -l 546 ll /usr/share/doc/ | grep bc-1.06.95 547 ll /usr/share/doc/bc-1.06.95/ 548 echo '$PATH' 549 echo "$PATH" 550 echo "This system's name is $(hostname) " 551 echo "i am `whoami` " 552 echo file{1,3,5\ 553 echo file{1,3,5} 554 echo file{1..5} 555 echo file{a..z} 556 echo file{1,3,5} 557 echo file{1..5} 558 echo file{1..10..2} 559 w 560 who 561 whoami 562 who 563 lsblk 564 rmp -ivh /run/media/root/CentOS\ 7\ x86_64/Packages/screen-4.1.0-0.25.20120314git3c2946.el7.x86_64.rpm 565 lsblk 566 rpm -ivh /run/media/root/CentOS\ 7\ x86_64/Packages/screen-4.1.0-0.25.20120314git3c2946.el7.x86_64.rpm 567 screen 568 who 569 screen 570 who 571 exit 572 who 573 exit 574 screen -S help_me 575 screen -l 576 screen -l 577 echo $LANG 578 cat /etc/issue 579 cat /etc/motd 580 who 581 ss -ntl 582 screen -ls 583 ps -ef | grep ping 584 ps -ef | grep ping | grep -v grep 585 ps -ef | grep ping 586 \ 587 screen -ls 588 screen -r 589 screen -l 590 who 591 screen -l 592 ps -ef | grep ping 593 screen -l 594 who 595 ls 596 who 597 screen -ls 598 screen -x help_me 599 who 600 ifconfig 601 history [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# history #查看當前命令行中執行的歷史命令。 ...... 588 screen -r 589 screen -l 590 who 591 screen -l 592 ps -ef | grep ping 593 screen -l 594 who 595 ls 596 who 597 screen -ls 598 screen -x help_me 599 who 600 ifconfig 601 history [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# !600 #執行history中記錄的第600條命令 ifconfig ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.30.1.101 netmask 255.255.255.0 broadcast 172.30.1.255 inet6 fe80::20c:29ff:febe:114d prefixlen 64 scopeid 0x20<link> ether 00:0c:29:be:11:4d txqueuelen 1000 (Ethernet) RX packets 215554 bytes 280803323 (267.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 33311 bytes 4107126 (3.9 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 860 bytes 74340 (72.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 860 bytes 74340 (72.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:a9:de:9b txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# history #查看當前命令行中執行的歷史命令。 ...... 589 screen -l 590 who 591 screen -l 592 ps -ef | grep ping 593 screen -l 594 who 595 ls 596 who 597 screen -ls 598 screen -x help_me 599 who 600 ifconfig 601 history 602 ifconfig 603 history [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# !-5 #執行倒數第5條的歷史命令。或者你按鍵盤的上鍵按5次也能夠~ who root :0 2019-08-02 16:30 (:0) root pts/0 2019-08-02 16:37 (:0) root pts/2 2019-09-03 19:49 (172.30.1.1) root pts/5 2019-09-03 19:49 (172.30.1.1:S.0) [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# history ...... 601 history 602 ifconfig 603 history 604 who 605 echo $HISTSIZE 606 set HISTSIZE=20 607 echo $HISTSIZE 608 set $HISTSIZE=20 609 echo $HISTSIZE 610 cat ~/.bash_history 611 cat ~/.bash_history | wc -l 612 history 613 cat ~/.bash_history | wc -l 614 history [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# rm -rf ~/.bash_history #刪除存放歷史命令的文件 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# history -c #清空內存中的history命令, [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# history #咱們發現命令被狀況啦! 1 history [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# logout #退出當前終端,推出後,內存中保存的history命令會被從新刷新到"~/.bash_history"文件中,我設置了自動重連,鏈接後咱們繼續觀察歷史命令 Connection closed by foreign host. Disconnected from remote host(node101.yinzhengjie.org.cn) at 17:29:20. Type `help' to learn how to use Xshell prompt. [c:\~]$ Reconnecting in 1 seconds. Press any key to exit local shell. . Host 'node101.yinzhengjie.org.cn' resolved to 172.30.1.101. Connecting to 172.30.1.101:22... Connection established. To escape to local shell, press 'Ctrl+Alt+]'. Last login: Tue Sep 3 20:30:46 2019 from 172.30.1.1 welcome to https://www.cnblogs.com/yinzhengjie/ !!! [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# history #再次查看,發現以前的歷史命令都不存在啦 1 history [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
4>.命令歷史相關環境變量
HISTSIZE:命令歷史記錄的條數
HISTFILE:指定歷史文件,默認爲~/.bash_history
HISTFILESIZE:命令歷史文件記錄歷史的條數
HISTTIMEFORMAT=「%F %T 「 顯示時間 HISTIGNORE=「str1:str2*:… 「 忽略str1命令,str2開頭的歷史
控制命令歷史的記錄方式:
環境變量:HISTCONTROL
ignoredups 默認,忽略重複的命令,連續且相同爲「重複」
ignorespace 忽略全部以空白開頭的命令
ignoreboth 至關於ignoredups, ignorespace的組合
erasedups 刪除重複命令
export 變量名="值「
存放在 /etc/profile 或 ~/.bash_profile
[root@node101.yinzhengjie.org.cn ~]# echo $HISTSIZE #歷史默認是保存1000條 1000 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# grep HISTSIZE /etc/profile #咱們經過查看"/etc/profile"文件不難發現的肯定義的HISTSIZE爲1000 HISTSIZE=1000 export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# sed -i 's/HISTSIZE=1000/HISTSIZE=20/' /etc/profile #咱們將"HISTSIZE"的大小改成20,爲了安全起見。 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# grep HISTSIZE /etc/profile #發現配置文件被改動了 HISTSIZE=20 export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# echo $HISTSIZE #配置文件被改動了沒錯,可是並無當即生效呢 1000 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# source /etc/profile #因而咱們須要從新加載配置文件內容 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# echo $HISTSIZE #Duang~至此咱們修改爲功啦~ 20 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/profile.d/env.sh #咱們建議將系統環境變量配置保存到一個指定的文件中,自定義history的輸出格式 #!/usr/bin/env python #_*_conding:utf-8_*_ #@author :yinzhengjie #blog:http://www.cnblogs.com/yinzhengjie HISTTIMEFORMAT="%F %T " #就這一行命令是有效的,咱們給當前的命令添加時間,能夠記錄命令在什麼時候指定的命令的 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# history #查看當前的歷史命令記錄 3 2019-09-03 20:46:48 who 4 2019-09-03 20:46:48 screen -l 5 2019-09-03 20:46:48 who 6 2019-09-03 20:46:48 ifconfig 7 2019-09-03 20:46:48 history 8 2019-09-03 20:46:48 cat /etc/redhat-release 9 2019-09-03 20:46:48 history 10 2019-09-03 20:46:48 #!/usr/bin/env python 11 2019-09-03 20:46:48 #_*_conding:utf-8_*_ 12 2019-09-03 20:46:48 #@author :yinzhengjie 13 2019-09-03 20:46:48 cat /etc/profile.d/env.sh 14 2019-09-03 20:46:48 pwd 15 2019-09-03 20:46:48 history 16 2019-09-03 20:46:48 cat /etc/profile.d/env.sh 17 2019-09-03 20:46:48 HISTTIMEFORMAT=「%F %T\ 18 2019-09-03 20:46:48 HISTTIMEFORMAT=「%F %T 19 2019-09-03 20:46:48 vi /etc/profile.d/env.sh 20 2019-09-03 20:46:50 history 21 2019-09-03 20:47:00 cat /etc/profile.d/env.sh 22 2019-09-03 20:47:14 history [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# cat ~/.bash_history #查看配置文件中記錄的歷史命令 who screen -S help_me who screen -l who ifconfig history cat /etc/redhat-release history #!/usr/bin/env python #_*_conding:utf-8_*_ #@author :yinzhengjie cat /etc/profile.d/env.sh pwd history cat /etc/profile.d/env.sh HISTTIMEFORMAT=「%F %T\ HISTTIMEFORMAT=「%F %T vi /etc/profile.d/env.sh [root@node101.yinzhengjie.org.cn ~]#
十一.Bash的快捷鍵
Ctrl + l 清屏,至關於clear命令 Ctrl + o 執行當前命令,並從新顯示本命令 Ctrl + s 阻止屏幕輸出,鎖定 Ctrl + q 容許屏幕輸出 Ctrl + c 終止命令 Ctrl + z 掛起命令 Ctrl + a 光標移到命令行首,至關於Home Ctrl + e 光標移到命令行尾,至關於End Ctrl + f 光標向右移動一個字符 Ctrl + b 光標向左移動一個字符 Alt + f 光標向右移動一個單詞尾 Alt + b 光標向左移動一個單詞首 Ctrl + xx 光標在命令行首和光標之間移動 Ctrl + u 從光標處刪除至命令行首 Ctrl + k 從光標處刪除至命令行尾 Alt + r 刪除當前整行 Ctrl + w 從光標處向左刪除至單詞首 Alt + d 從光標處向右刪除至單詞尾 Ctrl + d 刪除光標處的一個字符 Ctrl + h 刪除光標前的一個字符 Ctrl + y 將刪除的字符粘貼至光標後 Alt + c 從光標處開始向右更改成首字母大寫的單詞 Alt + u 從光標處開始,將右邊一個單詞更改成大寫 Alt + l 從光標處開始,將右邊一個單詞更改成小寫 Ctrl + t 交換光標處和以前的字符位置 Alt + t 交換光標處和以前的單詞位置 Alt + N 提示輸入指定字符後,重複顯示該字符N次 注意:Alt組合快捷鍵常常和其它軟件衝突