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
下一篇 2018-04-24

相关推荐

  • ansile

    ansible ansible 是一个自动化运维工具,他是基于python语言实现,基于openssh安全的工具 特性: 1)幂等性:一个任务执行1遍和执行n遍效果一样 ,不因重复执行带来意外情况2)无需代理不依赖PKI(无需ssl)3)可使用任何编程语言写模块4)YAML格式,编排任务,支持丰富的数据结构5)较强大的多层解决方案 ansible可以直接由一…

    Linux笔记 2018-06-04
  • 第三周作业20180528

    1、 列出登录用户 登录用户去重 2、 显示最后登录用户信息 3、 查看使用最多的SHELL 4、 5 6 7、 8、 9、 10、    

    2018-05-28
  • centos6启动流程

    这是第四次

    2018-05-13
  • liunx 基础

    简单命令:

    Linux笔记 2018-04-01
  • linux练气篇

    1、描述计算机的组成及其功能。
    2、按系列罗列Linux的发行版,并描述不同发行版之间的联系与区别。
    3、描述Linux的哲学思想,并按照自己的理解对其进行解释性描述。
    4、说明Linux系统上命令的使用格式;详细介绍ifconfig、echo、tty、startx、export、pwd、history、shutdown、poweroff、reboot、hwclock、date命令的使用,并配合相应的示例来阐述。
    5、如何在Linux系统上获取命令的帮助信息,请详细列出,并描述man文档的章节是如何划分的。
    6、请罗列Linux发行版的基础目录名称命名法则及功用规定

    Linux笔记 2018-05-12
  • 数组复制 expect

    变量                                                                                       /* 内存空间 存储单个元素 */ 数组 /* 连续的内存空间 存储多个元素 */ /* 多个变量的集合 */ 数组名 声明数组 /* declare -a Ary_Name */ …

    Linux笔记 2018-07-08