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运维学习的常用命令总结以及需要注意的地方(1)

    逆水行舟,不进则退 ,大家共勉之!
    1.在linux安装阶段可能会用到的命令
    2.设置网络相关的命令
    3.用户频道的切换以及用户相关信息的查看
    4.系统当前的shell信息以及别名、内部命令、外部命令相关

    2018-04-02
  • hell脚本基础知识详细介绍

    Shell本身是一个用C语言编写的程序,它是用户使用Linux的桥梁。Shell既是一种命令语言,又是一种程序设计语言。作为命令语言,它交互式地解释和执行用户输入的命令;作为程序设计语言,它定义了各种变量和参数,并提供了许多在高级语言中才具有的控制结构,包括循环和分支。 它虽然不是Linux系统核心的一部分,但它调用了系统核心的大部分功能来执行程序、建立文件…

    Linux笔记 2018-05-14
  • grub stage1、grub stage1.5、grub stage2的破坏与修复实验

    grub stage1、grub stage1.5、grub stage2的破坏与修复实验 一、破坏并修复grub  stage1       446个字节 hexdump  -C  /dev/sda  -n  512             查看MBR的512个字节   dd    if=/dev/zero    of=/dev/sda    b…

    Linux笔记 2018-05-13
  • 第七周作业

      1、创建一个10G分区,并格式为ext4文件系统;  (1) 要求其block大小为2048, 预留空间百分比为2,   卷标为MYDATA, 默认挂载属性包含acl;  (2) 挂载至/data/mydata目录,要求挂载时禁止程序自动运行,且不更新文件的访问时间戳; 1.创建分区/dev/sdb1,容量为10G fdisk /dev/sdb…

    2018-05-02
  • 路由设置

    路由

    Linux笔记 2018-05-05