Linux相关命令的总结,包括网络、操作系统、文件、脚本、环境配置
网络相关 1 2 3 4 5 6 7 8 9 10 11 12 vim /etc/sysconfig/network-scripts/ifcfg-ens33 TYPE="Ethernet" BOOTPROTO="static" NAME="ens33" DEVICE="ens33" ONBOOT="yes" IPADDR="192.168.25.160" GATEWAY="192.168.25.2" NETMASK="255.255.255.0" DNS1="114.114.114.114"
1 2 3 4 5 [root@localhost ~] default via 192.168.25.2 dev ens33 proto static metric 100 192.168.25.0/24 dev ens33 proto kernel scope link src 192.168.25.160 metric 100
如果遇到主机无法解析问题,直接重启网络,因为可能是dns解析出问题了,重启刷新下 1 2 3 4 systemctl restart NetworkManager systemctl restart network
防火墙 查看防火墙状态:systemctl status firewalld.service 关闭防火墙:systemctl stop firewalld.service 永久关闭:systemctl disable firewalld.service
开启指定端口 先开启防火墙:systemctl start firewalld
再开放8080端口:firewall-cmd –zone=public –add-port=8080/tcp –permanent
最后刷新配置:firewall-cmd –reload
操作系统相关 或者使用uname -a都能查到
1 2 [root@localhost ~] Linux version 3.10.0-957.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) )
1 2 [root@localhost ~] Intel(R) Core(TM) i5-7300HQ CPU @ 2.50GHz
1 2 3 4 5 6 7 8 9 10 11 12 yum install -y redhat-lsb [root@localhost ~] LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.6.1810 (Core) Release: 7.6.1810 Codename: Core cat /etc/os-release
top命令,实时查看系统运行信息,包括cpu、内存各种东西占用 文件操作相关 ll命令
压缩文件
脚本运行相关 startup脚本文件启动问题:
1 linux -bash: ./startup.sh: /bin/sh^M: 坏的解释器: 没有那个文件或目录:解决办法:sed -i 's/\\r$//' [startup.sh](<http://startup.sh/>)
Java 查看java安装目录:echo $JAVA_HOME
echo $PATH
执行jar包,通用脚本文件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #!/bin/bash jar_pid=`ps -ef|grep -v grep | grep 'example.jar' |awk '{ print $2 }' ` echo $jar_pid if [ ! -n "$jar_pid " ]; then echo 'will redploy.' rm -rf nohup.out nohup java -Xms512m -Xmx2048m -Dspring.profiles.active=pro -jar example.jar & echo 'redploy success0.' else kill -9 $jar_pid echo 'kill' $jar_pid rm -rf nohup.out nohup java -Xms512m -Xmx2048m -Dspring.profiles.active=pro -jar example.jar & echo 'redploy success1.' fi
环境配置相关 centos7.3安装MySQL5.7 Centos7.3安装和配置Mysql5.7