Linux基础入门
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.用户登录
root 用户
一个特殊的管理帐户
也被称为超级用户
root已接近完整的系统控制
对系统损害几乎有无限的能力
除非必要,不要登录为root
普通( 非特权 )用户
权限有限
造成损害的能力比较有限
二.终端terminal
设备终端
主要指物理设备,可以看得见摸得着的,如:键盘、鼠标、显示器。
物理终端( /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
三.交互式接口
交互式接口:
启动终端后,在终端设备附加一个交互式应用程序
GUI:Graphic User Interface(图形化运行环境,一般适合初学者学习)
X protocol, window manager, desktop
Desktop:
GNOME (C, 图形库gtk),
KDE (C++,图形库qt)
XFCE (轻量级桌面)
CLI:Command Line Interface(字符运行环境,生产环境一般用这种)
shell程序
四.Shell解释器
1>.什么是shell
Shell是Linux系统的用户界面,提供了用户与内核进行交互操作的一种接口。 它接收用户输入的命令并把它送入内核去执行
shell也被称为LINUX的命令解释器(command interpreter)
shell是一种高级程序设计语言
2>.各种shell
一.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>.命令提示符
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则被省略 :显示时间为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] [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] [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) #操作系统会发出警告声 backspace #退格键,如果后面有数据的话会删除前面一个字符 c suppress further output #最后不加上换行符,可以取消换行,和-n效果类似 e escape character #escape,相当于 33 f form feed #和纵向制表符类似 new line #添加换行,换行且将光标移至行首 carriage return #回车,即将光标移至行首,但不换行 horizontal tab #制表符,一般为4个连续的空格 v vertical tab #纵向的制表符 \ backslash #我们知道""时转义符,想要打印反斜线的话,就得使用转义符。 nnn 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 "abcxyz" #我们发现字符c被删除啦 abxyz [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "abcc" #我们不难发现,默认的换行符被取消啦! abc[root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "abc 123 xyz" #注意,这里有2个换行符 abc 123 xyz [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "yinzhengjie 2019 jason" #让字符之间距离间隔一个制表符 yinzhengjie 2019 jason [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "yinzhengjiev2019vjason" #我们可以使用纵向的制表符,我们发现数据本来应该连续写的,但是使用纵向制表符后,数据竟然换换行且未到行的首部! yinzhengjie 2019 jason [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# echo -e "yinzhengjiev2019vjason" | wc -l #我们使用换行的命令统计改行的大小,返现其仅为1行内容。 1 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "yinzhengjief2019ejason" yinzhengjie 2019ason [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "yinzhengjief2019fjason" yinzhengjie 2019 jason [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "yinzhengjie 2019" #不难发现,我们进行回车后,之前的数据被覆盖掉啦,因为我没有换行,直接将光标移至行首了,新数据会把之前的数据覆盖! 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 "