systemctl命令

systemctl

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

实例

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
原文地址:http://man.linuxde.net/systemctl

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/96942

(2)
小孜然小孜然
上一篇 2018-04-23 22:59
下一篇 2018-04-24 10:54

相关推荐

  • Linux系统软件包管理介绍

    Linux发行版中附带有成千上万的可用包,其中包括了Internet工具、开发工具、办公工具、游戏等,如果你没有选择完整安装,则只会安装这些包的“子集”,如何删除不想要的包,如何安装遗漏的包,学习LInux系统的软件包管理将解决你的这些问题

    2018-04-20
  • Linux练习题-用户权限管理

    用户权限管理

    2018-03-29
  • ssh等

    SSH端口转发 SSH会自动的加密和解密所有SSH客户端与服务器之间的网络数据;同时也可以将其他TCP端口的数据加密转发,这一过程叫“隧道”,这样也可以减少防火墙开启的端口。 实现过程是数据首先通过连接本机的某一个端口,被当做ssh协议数据发送给ssh服务器,ssh服务器解密再发给远程主机的端口 本地转发: -L localport:remotehost:r…

    2018-05-28
  • 第三周

    CMD=”hostname”echo $CMDhostname$CMDcentos6.com 全局配置文件/etc/profile 定义变量的/etc/profile.d/*.sh /etc/profile.d/env.sh在这该/etc/bashrc 放别名个人配置文件~/.bash_profile 定义变量的~/.bashrc.b…

    Linux笔记 2018-04-15
  • 生产环境中数据文件删除,空间不释放问题

    首先数据文件删除文件系统空间不释放的问题不只出现在Linux平台,所有平台都可能有这样的问题。这里只是在Linux平台做一些测试,其他平台类似;其次只有将数据文件存放在文件系统中才会有此类问题。空间没有释放我们可能是通过df命令确认的,当我们用du去扫描目录的大小可能会发现df和du两个命令看到的空间使用情况是不同的,可能差别很大,找了一些文档,解决了这个问题;写这篇博客,希望跟大家分享一下。

    2018-05-18
  • Linux文本处理三剑客之grep 和 正则表达式

    本文主要介绍:1、文本处理工具grep 2、正则表达式

    2018-04-17