文件压缩与打包
常见压缩包扩展名:
gzip -c aa.log > aa.log.gz 压缩后源文件还在
bzip2 -vc aa.txt > bb.txt.bz2 压缩比比gzip更佳
tar 命令查询shells文件在压缩包中是否存在
[root@node01 ~]# tar -ztvf etc01.tar.gz |grep 'shell'
-rw-r--r-- root/root 42 2018-11-18 18:46 etc/shells
tar 命令仅解压某个文件:
[root@node01 ~]# tar -zxvf etc01.tar.gz etc/shells
etc/shells
其中etc/shells 是想要的单个文件
rpm安装软件
查询是否已经安装某个软件包:
rpm -qa | grep jdk
查询包中所包含的目录及文件:
rpm -ql lrzsz
查询包的说明:
rpm -qi lrzsc
rpm卸载:
rpm -e 软件包
yum安删更软件
安装某个包:
yum install xxx -y 其中那个-y表示自动安装完成不用手动输入y
yum remove xxx -y 卸载
yum update xxx 更新包
shell命令
在/etc/profile中最后编辑jdk JAVA_HOME环境变量:
export JAVA_HOME=/usr/local/jdk1.8.0_201
export PATH=$PATH:$JAVA_HOME/bin
例如:
[root@node01 ~]# a=192.168.1.2
[root@node01 ~]# b='192.168.1.2'
[root@node01 ~]# c="192.168.1.2"
[root@node01 ~]# echo "a=$a"
a=192.168.1.2
[root@node01 ~]# echo "b=$b"
b=192.168.1.2
[root@node01 ~]# echo "c=${c}"
c=192.168.1.2
例如:
[root@node01 ~]# test=zhangsan
[root@node01 ~]# echo $test
zhangsan
[root@node01 ~]# unset test
[root@node01 ~]# echo $test
[root@node01 ~]#
shell管道命令
grep命令
–color 将匹配字符加颜色