使用 systemctl 管理服务

systemctl 就是 service 和 chkconfig 这两个命令的整合,在 CentOS 7 就开始被使用了,systemctl是系统服务管理器命令,它实际上将 service 和 chkconfig 这两个命令组合到一起。

Syetemclt 管理服务常用命令

、启动服务:systemctl start httpd
、关闭服务:systemctl stop httpd
、重启服务:systemctl restart httpd
、查看一个服务的状态:systemctl status httpd
、查看一个服务是否在运行:systemctl is-active httpd
、查看当前已经运行的服务:systemctl list-units -t service
、列出所有服务: systemctl list-units -at service 注意顺序
. 设置开机自启动: systemctl enable httpd
. 停止开机自启动: systemctl disable httpd
、列出所有自启动服务:
systemctl list-unit-files|grep enabled
systemctl list-unit-files|grep disabled
systemctl list-unit-files|grep disabled | grep httpd
、使指定服务从新加载配置:systemctl reload httpd

Firewalld 防火墙的设置

从 CentOS7(RHEL7)开始,官方的标准防火墙设置软件从 iptables 变更为 firewalld,相信不少习惯使用iptables 的人会感到十分不习惯,但实际上 firewalld 更为简单易用。

firewalld 的基本使用:

启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld
开机禁用 : systemctl disable firewalld
开机启用 : systemctl enable firewalld

配置 firewall-cmd :

查看版本: firewall-cmd --version
查看帮助: firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
查看区域信息: firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态: firewall-cmd --panic-off
查看是否拒绝: firewall-cmd --query-panic

怎么开启一个端口:

firewall-cmd --zone=public --add-port=/tcp --permanent (–permanent 永久生效,没有此参数重 启后失效)
重新载入:
firewall-cmd --reload 修改 firewall-cmd 配置后必须重启
查看:
firewall-cmd --zone= public --query-port=/tcp
删除:
firewall-cmd --zone= public --remove-port=/tcp --permanent

SELinux 防火墙的设置

安全增强型 Linux(Security-Enhanced Linux)简称 SELinux,它是一个 Linux 内核模块,也是 Linux 的一个安全子系统。 SELinux 主要由美国国家安全局开发。2.6 及以上版本的 Linux 内核都已经集成了 SELinux 模块。

SELinux 的结构及配置非常复杂,而且有大量概念性的东西,要学精难度较大。很多 Linux 系统管理员嫌麻烦都把 SELinux 关 闭了。阿里云安装的 centos 默认已经关闭了。西部数码云服务器默认也是关闭的。

查看 SELinux 状态:

、/usr/sbin/sestatus -v  ##如果 SELinux status 参数为 enabled 即为开启状态
SELinux status: enabled
、 getenforce ##也可以用这个命令检查

关闭 SELinux:

、临时关闭(不用重启机器):
etenforce ##设置 SELinux 成为 permissive 模式
setenforce 设置 SELinux 成为 enforcing 模式 、修改配置文件需要重启机器:
修改/etc/selinux/config 文件
将 SELINUX=enforcing 改为 SELINUX=disabled

Linux_CentOS 中systemctl 管理服务、防火墙 firewalld 以及 SELinux 配置的更多相关文章

  1. 二进制编译安装nginx并加入systemctl管理服务

    一.安装nginx所需环境 # yum install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel -y 二.安装ngi ...

  2. CentOS 6.9下的Setup工具(用于管理服务/防火墙/网络配置/验证服务)

    说明:Setup工具套件好像是CentOS下特有的用于管理服务/防火墙/网络配置等,其实就是基于命令行模式界面的GUI工具.唯一特点就是方便. 安装: #安装Setup命令工具 yum -y inst ...

  3. Linux学习-透过 systemctl 管理服务

    透过 systemctl 管理单一服务 (service unit) 的启动/开机启动与观察状态 一般来说,服务的启动有两个阶段,一 个是『开机的时候设定要不要启动这个服务』, 以及『你现在要不要启动 ...

  4. RHEL7使用systemctl管理服务

    1.   systemctl命令 说明 systemctl    start   [unit type] 启动服务 systemctl    stop   [unit type] 停止服务 syste ...

  5. 使用 Centos 7 的 systemctl 管理服务

    CentOS 7的服务systemctl脚本存放在:/usr/lib/systemd/,有系统(system)和用户(user)之分,像需要开机不登陆就能运行的程序,存系统服务里即:/usr/lib/ ...

  6. 使用systemctl管理服务

    系统服务,开机不需要登录就能运行的程序(相当于开机自启)/usr/lib/systemd/system 用户服务,需要登录后才能运行的程序/usr/lib/systemd/user 目录下又存在两种类 ...

  7. CentOS7下普通账号通过systemctl管理服务需要输入root密码问题

    问题描述: 使用普通账号test通过systemctl启动系统服务提示需要输入root密码: 解决方案: 根据上面提示得知权限由polkit进行管理,对应的是org.freedesktop.syste ...

  8. Windows中的DNS服务——正向解析&反向解析配置 分类: AD域 Windows服务 2015-07-16 20:21 19人阅读 评论(0) 收藏

    坚信并为之坚持是一切希望的原因. DNS服务是AD域不可或缺的一部分,我们在部署AD域环境时已经搭建了DNS服务(windows server 2008 R2域中的DC部署),但是DNS服务的作用还是 ...

  9. CentOS7 使用systemctl来管理服务

    1.建立service文件 以tomcat为例 , 建立tomcat.service文件 #服务说明 [Unit] #服务描述 Description=Tomcat Service #前置需要启动的服 ...

随机推荐

  1. 随笔小skill

    1.用拉链函数zip()将字典转换成元组对!函数中的两个参数必须是序列!p = {'name':'zhangsanfeng','age':18,'gender':'nan'}print(list(zi ...

  2. MySQL- Host 'xxx' is not allowed to connect to this MySQL server.

    mysql中有个系统数据库mysql,里面有张表user记录该实例的用户及其权限. 第一种方法 将其用户root的host改为%,即允许所有客户端连接. FLUSH PRIVILEGES;是将修改生效 ...

  3. Upgrade Windows Server 2016 to Windows Server 2019

    Pre-Upgrade Upgrade path: Windows Server 2016 can be upgraded to Windows 2019 in a single upgrade pr ...

  4. python爬取数据分析

    一.python爬虫使用的模块 1.import requests 2.from bs4 import BeautifulSoup 3.pandas 数据分析高级接口模块 二. 爬取数据在第一个请求中 ...

  5. 前端安全问题之CSRF和XSS

    一.CSRF 1.什么是 CSRF CSRF(全称 Cross-site request forgery),即跨站请求伪造 2.攻击原理 用户登录A网站,并生成 Cookie,在不登出的情况下访问危险 ...

  6. Codeforces C. Jzzhu and Cities(dijkstra最短路)

    题目描述: Jzzhu and Cities time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  7. 《基于C/S和B/S混合结构的中职学校教务管理系统设计与实现》论文笔记(十六)

    标题:基于C/S和B/S混合结构的中职学校教务管理系统设计与实现 一.基本信息 时间:2008 来源:中 国 海 洋 大 学 关键词:: 教务管理信息系统;C/S和B/S混合结构;UML;USE CA ...

  8. shortcuts for contructor 创建对象捷径

  9. MySQL——时间戳和时间的转化

    前言 Mysql中时间戳和时间的转化 时间转时间戳 select unix_timestamp('2019-7-29 14:23:25'); 时间戳转时间 select from_unixtime(1 ...

  10. Python 代码混淆和加密技术

    动机 Python进行商业开发时, 需要有一定的安全意识, 为了不被轻易的逆向. 混淆和加密就有所必要了. 混淆 为了增加代码阅读的难度, 源代码的混淆非常必要, 一个在线的Python代码混淆网站. ...