systemctl 命令的用法

摘要:
(所以我找到的大部分教程都已经过时了……我仍然需要去fedora.org阅读中文文档。。。
对比表,以 apache / httpd 为例
任务旧指令新指令
使某服务自动启动chkconfig --level 3 httpd onsystemctl enable httpd.service
使某服务不自动启动chkconfig --level 3 httpd offsystemctl disable httpd.service
检查服务状态service httpd statussystemctl status httpd.service (服务详细信息) systemctl is-active httpd.service (仅显示是否 Active)
显示所有已启动的服务chkconfig --listsystemctl list-units --type=service
启动某服务service httpd startsystemctl start httpd.service
停止某服务service httpd stopsystemctl stop httpd.service
重启某服务service httpd restartsystemctl restart httpd.service

在Fedora中使用的是新的systemd系统和服务管理程序, 主要使用systemctl控制,配置在/etc/systemd/下。功能更加强大。(因此我找到的教程大部分都过时了。。。还是得上fedora.org看中文文档。。。)

下面以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        

免责声明:文章转载自《systemctl 命令的用法》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Mac下IDEA启动Springboot项目慢Greenplum-cc-web监控软件安装下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

linux开机自启动

linux下添加简单的开机自启动脚本 在linux的使用过程中,我们经常会碰到需要将某个自定义的应用程序设置为开机自启动以节省操作时间,这里提供两个设置开机自启动的方法。 注:博主使用的ubuntu-16.04进行实验,其它版本可能有偏差,但实现原理类似。 rc.local 在rc.local脚本中添加开机自启动程序 ubuntu在开机过程之后,会执行/e...

Ambari2.7.4+HDP3.1.4在centos7.6部署

一.下载安装包 使用在线安装特别慢,所有的安装包加起来有9个G左右,所以需要先下载相关安装包到服务器,通过配置本地源的方式来实现的离线安装。 在私有集群中部署时,客户机房的网络情况不可预测,因此也需要使用离线部署的方式。 根据官方文档 https://docs.cloudera.com/HDPDocuments/Ambari-2.7.4.0/bk_am...

linux下关闭桌面模式使用命令行模式及其它模式

vim/etc/inittab 把其中的id:5:initdefault中的5改为3。 Linux操作系统有六种不同的运行级(run level),在不同的运行级下,系统有着不同的状态,这六种运行级分别为:0:停机(记住不要把initdefault 设置为0,因为这样会使Linux无法启动)1:单用户模式,就像Win9X下的安全模式。2:多用户,但是没有...

转载 CentOS 7安装GNOME桌面 和 配置 VNC 服务器

CentOS 7安装GNOME桌面 和 配置 VNC 服务器这是一个关于怎样在你的 CentOS 7 上安装GNOME桌面 和 配置 VNC 服务器的教程。当然这个教程也适合 RHEL 7 安装GNOME桌面 和 配置 VNC 服务器。 1、安装桌面yum check-updateyum groupinstall "X Window System" "GN...

apache 访问权限出错,apache selinux 权限问题, (13) Permission Denied

今天在使用 httpd 做文件服务器的时候,发现 png 图像没有打开,但是原本www/html 文件夹内部的文件就可以打开。后来猜测是selinux 的问题,之前一直想写一篇关于selinux 的博文,现在先在这里提到一点吧。 欲详细解决  (13) Permission Denied 问题, 可以参考apache 官方文档 (13) Permissio...

Linux之防火墙配置

Centos 7 firewall : 1、firewalld的基本使用 启动: systemctl start firewalld 关闭: systemctl stop firewalld 查看状态: systemctl status firewalld  开机禁用  : systemctl disable firewalld 开机启用  : sys...