LINUX日常操作二

参见:Linux日常操作一

 selinux 开启和关闭

一、查看SELinux状态:
1、/usr/sbin/sestatus -v      ##如果SELinux status参数为enabled即为开启状态
SELinux status:                 enabled
2、getenforce                 ##也可以用这个命令检查
二、关闭SELinux:
1、临时关闭(不用重启机器):
setenforce 0                  ##设置SELinux 成为permissive模式
                                     ##setenforce 1 设置SELinux 成为enforcing模式
2、修改配置文件需要重启机器:
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
重启机器即可

打开和关闭Swap

1、关闭SWAP

一般用于大物理内存的服务器

swapoff -a

执行以上命令,则可以关闭SWAP分区。

2、开启SWAP

swapon -a

执行以上命令,则可以开启SWAP分区。

3.永久关闭swap

sed -ri 's/.*swap.*/#&/' /etc/fstab

ntp集群服务器时间同步

参考:https://www.cnblogs.com/quchunhui/p/7658853.html

 防火墙的关闭与停止

systemctl stop firewalld.service
systemctl disable firewalld.service

 centos7使用阿里云的yum源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
yum update

原文地址:https://www.cnblogs.com/Netsharp/p/10764509.html