Skip to main content

centos7常用操作命令

查看防火墙是否运行

firewall-cmd --state

启动:

systemctl start firewalld

关闭:

systemctl stop firewalld

查看状态:

systemctl status firewalld 

开机禁用 :

systemctl disable firewalld

开机启用 :

systemctl enable firewalld

查看已经增加的信任

firewall-cmd --list-port
firewall-cmd --list-all

信任

firewall-cmd --permanent --zone=public --add-port=9151/tcp
firewall-cmd --permanent --zone=public --add-port=30000-50000/udp
firewall-cmd --permanent --zone=public --add-rich-rule 'rule family="ipv4" source address="开放的ip" port protocol="tcp" port="3309" accept'

打开端口限制ip

firewall-cmd --permanent --zone=public --add-rich-rule 'rule family="ipv4" source address="192.168.1.24" port protocol="tcp" port="3309" accept'
firewall-cmd --reload

移除信任:

firewall-cmd --permanent --zone=public --remove-port=12345/tcp

firewall-cmd --permanent --zone=public --remove-rich-rule 'rule family="ipv4" source address="远程ip" port protocol="tcp" port="8840" accept'
firewall-cmd --reload

修改时区至首尔

vi /etc/sysconfig/clock
ZONE="Asia/Seoul"
UTC=false
ARC=false

ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
/sbin/hwclock --systohc
ntpdate cn.pool.ntp.org

远程拷贝文件

scp -P [port] /home/source.jar user@remotehost:/home/target.jar

远程登录

ssh -p [port] user@remotehost

查找日志

find /home/Logs/ -name '*.log' |xargs grep 'keyword'