`

centos7服务管理、防火墙和selinux设置

 
阅读更多
1.服务管理
    设置服务(service)开机自启和关闭开机自启
systemctl enable/disable service
    设置服务启动/重启/关闭
systemctl start/restart/stop service
2.防火墙(firewalld)启动与关闭
    防火墙开机自启
    systemctl enable firewalld
    防火墙关闭开机自启
    systemctl disable firewalld
    设置防火墙启动/重启/关闭
systemctl start/restart/stop firewalld
3.selinux设置与查看和修改运行模式
  设置
    vi /etc/selinux/config
    找到SELINUX=enforcing这一行
    可以修改为以下三个模式
    SELINUX=enforcing 强制模式(默认)
    SELINUX=permissive 宽容模式(有警告)
    SELINUX=disabled 关闭
   
   查看
    getenforce
   修改运行模式
    setenforce 0|1
    0 宽容模式(permissive)
    1 强制模式(disabled)
   
   
systemctl 是系统服务管理器命令,它实际上将 service 和 chkconfig 这两个命令组合到一起。

任务 旧指令 新指令
使某服务自动启动 chkconfig –level 3 httpd on systemctl enable httpd.service
使某服务不自动启动 chkconfig –level 3 httpd off systemctl disable httpd.service
检查服务状态 service httpd status systemctl status httpd.service (服务详细信息) systemctl is-active httpd.service (仅显示是否 Active)
显示所有已启动的服务 chkconfig --list systemctl list-units --type=service
启动某服务 service httpd start systemctl start httpd.service
停止某服务 service httpd stop systemctl stop httpd.service
重启某服务 service httpd restart systemctl restart httpd.service

使某个服务彻底无法启动(加入黑名单) systemctl umask httpd.service
移出黑名单      systemctl mask httpd.service
列出某个服务的依赖服务      systemctl list-dependencies sshd.service
列出所有活动的服务      systemctl list-units --type=service
列出所有服务包括不活动的服务      systemctl list-units --type=service --all
列出所有服务是否开机自启      systemctl list-unit-files --type=service
列出启动失败的服务      systemctl --failed --type=service

下面以nfs服务为例:

1.启动nfs服务

systemctl start nfs-server.service
2.设置开机自启动

systemctl enable nfs-server.service
3.停止开机自启动

systemctl disable nfs-server.service
4.查看服务当前状态

systemctl status nfs-server.service
5.重新启动某服务

systemctl restart nfs-server.service
6.查看所有已启动的服务

systemctl list -units --type=service
开启防火墙22端口

iptables -I INPUT -p tcp --dport 22 -j ACCEPT
如果仍然有问题,就可能是SELinux导致的

关闭SElinux:

修改/etc/selinux/config文件中的SELINUX=”” 为 disabled,然后重启

彻底关闭防火墙:

sudo systemctl status  firewalld.service
sudo systemctl stop firewalld.service         
sudo systemctl disable firewalld.service
分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

    CentOS 6.2 配置防火墙,关闭SELINUX

    CentOS 6.2 配置防火墙,关闭SELINUX.do

    CentOS关闭防火墙

    在Hadoop安装过程中需要关闭 防火墙和SElinux 及其配置文件设置

    centos7–DNS正(反)向解析

    #关闭防火墙和selinux [root@ c7-41 ~] systemctl stop firewalld [root@ c7-41 ~] setenforce 0 1,在主机A 服务端上安装DNS服务 [root@ c7-41 ~] yum -y install bind bind-utils bind-libs bind-chroot 2,修改...

    centos7.docx CentOS 7是一个基于Red Hat Enterprise Linux(RHEL)源代码构建的自由

    4. **安全性**:CentOS 7提供了与RHEL 7相同的安全性特性,包括安全更新、SELinux(安全增强型Linux)、防火墙等,以确保系统的安全性。 5. **软件包管理**:CentOS 7使用YUM(Yellowdog Updater, Modified)作为其...

    CentOS7 64位安装全过程

    集成了 Systemd 系统和服务管理工具,提高了系统的启动速度和管理效率。 资源描述: 官方网站:https://www.centos.org/ 下载页面:https://www.centos.org/download/ 官方文档:...

    CentOS 7下Samba服务器的安装与配置

    转载_ CentOS 7.3下Samba服务器的安装与配置_2017年9月2日 关闭防火墙:systemctl stop firewalld.service 临时关闭SeLinux:setenforce 0 开启samba服务:systemctl start smb

    CentOS 7 sshd 链接被拒绝问题解决办法

    1,服务器链接不上 ...2,centos7默认安装了防火墙不是iptables了 因为是本地测试,所以直接关闭防火墙,禁用开机启动。 systemctl stop firewalld systemctl disable firewalld 3,关闭selinux vi /etc/selinu

    centos7-shisanxiang.sh

    | 1 | 关闭防火墙selinux+关闭开机自启 | | 2 | 配置网易yum源 | | 3 | 使用Yum安装ntp并同步至阿里时间服务器 | | 4 | 使用Yum安装telnet/lsof/vim/unzip/lrzsz/wget/curl/tcpdump | | 5 | 配置ulimit(最大连接数...

    KVM在线yum源部署-centos stream

    1、 关闭防火墙和selinux 1.1关闭防火墙 1.2关闭selinux 2、 安装KVM/QEMU组件 3、 启动并设置开机启动 4、 检查KVM/QEMU是否正常运行 5、 查看kvm模块是否加载 6、 确认KVM/QEMU组件 7、 在libvirt目录中检查...

    CentOS7—HAProxy安装与配置详解

    关闭SElinux、配置防火墙 1、vi /etc/selinux/config #SELINUX=enforcing #注释掉 #SELINUXTYPE=targeted #注释掉 SELINUX=disabled #增加 :wq! #保存退出 setenforce 0 #使配置立即生效 2、vi /etc/sysconfig/...

    CentOS 8.bash

    centos8的网卡配置、防火墙、SElinux、yum源建立等基本操作,适用于初学者新安装系统之后的操作

    centos服务器初始化脚本

    0号脚本用于关闭selinux和防火墙 1号脚本用于安装jdk 2号脚本用于修改主机名和hosts文件 3号脚本用于安装gcc和expect命令 4号脚本用于设置集群免密登录 5号脚本用于设置时区和修改系统参数 6号脚本用于关闭swap分区 ...

    Linux-CentOS 7.6 系统初始化脚本

    内容概括:禁用防火墙,修改selinux,修改yum源,安装常用软件,同步系统时间,DNS域名配置,安装JDK-18,Tomcat,Mysql8,设置开机启动项-更新时间。 适合人群:Linux初学者 操作:用xftp将文件导入到Linux中,...

    centos7.6 常见问题,网络服务重启报错

    centos7.6 常见问题,网络服务重启报错vdss network.service重启报错 MTU值修改 关闭防火墙及Selinux

    CentOS7编译安装新版LNMP环境

    由于公司要求需要最新版的ZABBIX2.4.4需要最新版的系统CENTOS7和新版的LNMP环境,所以本人摸索着使用新版的环境搭建了LNMP系统,环境版本如下: 系统:CentOS 7 x86_64 NGINX:nginx-1.7.12 数据库:mariadb-...

    centos7-gitlab:仅一些脚本可帮助在CentOS 7上安装GitLab

    您将需要已安装mysql或mariadb并对其进行配置以进行网络访问您将需要以具有sudo访问权限(最好是sudo NOPASSWD访问权限)的用户身份运行它该脚本确实希望防火墙和selinux能够运行并强制执行CentOS7安装程序...

    centos7部署PXE批量安装内网服务器

    2.部署环境:(先关闭防火墙和selinux) 需要3台服务器,2台PXE服务器,一台RPM包管理服务器(内网YUM源服务器,需要两张网卡,一张指向公网一张指向内网) PXE_Server_mini:DHCP_Server+TFTP_Server+FTP/HTTP/NFS...

    关闭selinux(防火墙)方法分享

    默认装完CentOS,Selinux是打开的,这个你基本都是需要关闭,查看当前selinux的状态后,就可以按以下方法关闭selnux了

    Centos7实现MySQL基于日志还原数据的示例代码

    准备一台Centos7虚拟机,关闭防火墙和selinux,配置IP地址,同步系统时间,安装MySQL数据库 传统二进制日志还原数据 修改配置文件 [root@localhost ~]# vi /etc/my.cnf server-id=1 log-bin=binlog #重启数据库服务 ...

    Centos 7 部署 OpenStack_Rocky版高可用集群3-1

    文章目录Centos 7 部署 OpenStack_Rocky版高可用集群3-11、前期准备1.1 软硬件准备1.1.1组件1.1.2 网络拓扑(逻辑)1.1.3 物理拓扑(部分参考)1.2 配置hosts文件(集群所有电脑配置)1.3 节点间设置免密互相登陆1.4 ...

Global site tag (gtag.js) - Google Analytics