centos 指令

关闭防火墙

6.x

//临时关闭
service iptables stop
//禁止开机启动
chkconfig iptables off

7.x

//临时关闭
systemctl stop firewalld
//禁止开机启动
systemctl disable firewalld

如果安装了iptables-service,也可以使用下面的命令

yum install -y iptables-services
//关闭防火墙
service iptables stop
Redirecting to /bin/systemctl stop  iptables.service
//检查防火墙状态
service iptables status

关闭selinux

查看selinux状态

➜  ~ sestatus -v
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          disabled
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      31

Process contexts:
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
Init context:                   system_u:system_r:init_t:s0

File contexts:
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0
/etc/passwd                     system_u:object_r:passwd_file_t:s0
/etc/shadow                     system_u:object_r:shadow_t:s0
/bin/bash                       system_u:object_r:shell_exec_t:s0
/bin/login                      system_u:object_r:login_exec_t:s0
/bin/sh                         system_u:object_r:bin_t:s0 -> system_u:object_r:shell_exec_t:s0
/sbin/agetty                    system_u:object_r:getty_exec_t:s0
/sbin/init                      system_u:object_r:bin_t:s0 -> system_u:object_r:init_exec_t:s0
/usr/sbin/sshd                  system_u:object_r:sshd_exec_t:s0

临时关闭

##设置SELinux 成为permissive模式
##setenforce 1 设置SELinux 成为enforcing模式
setenforce 0

永久关闭

将SELINUX=enforcing改为SELINUX=disabled,设置后需要重启才能生效

vi /etc/selinux/config

SELINUX=disabled

修改hostname

7.x

# 使用这个命令会立即生效且重启也生效
sudo hostnamectl set-hostname prometheus

centos升级内核