系统配置查看
查看centos版本
cat /etc/redhat-release
查看CPU型号
cat /proc/cpuinfo | grep name | sort | uniq
lscpu
查看物理CPU数目
cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
查看每个物理CPU中core的个数(即核数)
cat /proc/cpuinfo| grep "cpu cores"| uniq
cat /proc/cpuinfo| grep "processor"| wc -l
CPU和内存使用情况
top -c
CPU占用最多的前10个进程
ps auxw|head -1;ps auxw|sort -rn -k3|head -10
内存消耗最多的前10个进程
ps auxw|head -1;ps auxw|sort -rn -k4|head -10
虚拟内存使用最多的前10个进程
ps auxw|head -1;ps auxw|sort -rn -k5|head -10
批量杀死进程
kill `ps -ef|grep 进程名 | grep -v grep|awk '{print $2}'`
du -sh *
查看当前目录下各个文件及目录占用空间大小
centos7.5防火墙配置
查看防火墙状态
systemctl status firewalld
查看已经开放的端口
firewall-cmd --list-ports
开启端口,以8888为例:
firewall-cmd --zone=public --add-port=8888/tcp --permanent
重启防火墙:
firewall-cmd --reload
关闭防火墙
firewall systemctl stop firewalld.service
关闭防火墙开机启动
firewall sustemctl disable firewalld.service
开机禁用
systemctl disable firewalld
开机启用
systemctl enable firewalld
iptables
service iptables status
查看防火墙状态
service iptables stop
关闭防火墙
service iptables start
启动防火墙
service iptables restart
重启防火墙
chkconfig iptables off
永久关闭防火墙
chkconfig iptables on
永久关闭后重启
常用操作
在文件中查询
grep+要查询的字段+文件
grep -l "今日停止" * -l : 列出文件内容符合指定的范本样式的文件名称。
shell脚本
jar包启停
查出进程杀掉 并重启
kill -9 `ps -ef|grep 8080 |awk '{print $2}'`
nohup /data/jdk1.8.0_191/bin/java -jar /data/xxx.jar --server.port=8080 >> nohup.out &
服务器之间复制
scp -r ./* 127.0.0.1:/data1/
主动从其他服务器拉取
sudo scp -r root@127.0.0.1:/data1/tydic/web/scpdir/dist .
连续执行shell命令可以有几种写法
command1; command2;command3
表示顺序执行command1,command2,command3而不管命令是否成功执行了。
command1 && command2 && command3
也表示顺序执行,但是与第一种写法的不同之处在于必须前面的成功执行后才会执行下一个命令,前一个失败了,则不会继续执行。
command1 || command2 || command3
这种写法各个命令之间是逻辑或的关系,表示如果command1成功执行了,那么就不再执行后面的命令了;而如果command1执行失败了则会执行command2,依次类推。
配置自定义系统命令 执行脚本
1.编辑 vi /etc/profile
2.#aams-membersystem
alias web_st='/app/sh/aams-membersystem-web.sh'
alias web_tf='tail -222f /app/log/aams-membersystem/all_cnki-aams-ms.log'