Rocky、Centos linux常用操作

修改Rocky服务器ip地址:

cd /etc/NetworkManager/system-connections/

修改文件中的ip

systemctl    restart    NetworkManager

查看本机公网ip地址:

curl http://cip.cc

curl http://ipinfo.io

查看防火墙白名单:

firewall-cmd --list-all

查看防火墙状态:

firewall-cmd --state

firewall 添加和删除白名单:


firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="需要访问后台的ip" port protocol="tcp" port="8080" accept'
firewall-cmd  --reload

添加端口:

firewall-cmd --permanent --add-port=443/tcp


3删除可访问的ip
firewall-cmd --permanent --remove-rich-rule='rule family="ipv4" source address="要删除的ip" port protocol="tcp" port="3306" accept'
firewall-cmd  --reload

sed 命令修改文件内容

sed -i "s/pam_deny.so/pam_deny.so onerr=fail deny=5 unlock_time=600 root_unlock_time=600/" /etc/pam.d/password-auth
sed -i "s/#ClientAliveInterval 0/ClientAliveInterval 600/" /etc/ssh/sshd_config
sed -i "s/local_users_only/local_users_only minlen=8 lcredit=-1 ucredit=-1 dcredit=-1 ocredit=-1 difok=5 enforce_for_root/" /etc/pam.d/system-auth
systemctl restart sshd

查看8080端口占用进行:

netstat -tulnp | grep :8080

查看cpu、系统版等

lscpu

uname -a

cat /etc/os-release

Centos8更换国内yum源:

# 1. 备份当前的YUM源配置文件
sudo cp -a /etc/yum.repos.d /etc/yum.repos.d.bak
 
# 2. 删除/移除当前的YUM源配置文件
sudo rm -f /etc/yum.repos.d/*.repo
 
# 3. 下载阿里云的CentOS 8 YUM源配置文件
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
 
# 4. 重新加载YUM源
sudo yum clean all
sudo yum makecache

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值