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基本指令

    hostname  完整主机名cat +文件路径  可查看文件信息cat /etc/shells  显示所有shelluname -r    查看内核版本ls cpu   查看cpu信息free命令  查看内存 后面加-k是显示的内存以kb为单位,-m(MB),-g(GB),-h显示易读单位lsblk  查看硬盘dmesg  查看计算机启动的一些相关信息dm…

    2018-07-22
  • 第二周笔记

    ### 4 月2日笔记 – #### IO重定向“`I:input指的是标准输入 描述符用0表示O:output指的是标准输入 描述符用1表示标准错误 描述符用2表示“`一般文件或者命令的标准输入是指的键盘,标准输出是值得终端窗口。我们用重定向来改变他们的方向大于号> 表示标准输出:把输出内容定向到一个文件中&#82…

    Linux笔记 2018-04-01
  • 第五周 软件包管理命令、制定定时任务和sed命令介绍

    1. RPM包管理 1.1 RPM简介 RPM类似于Windows系统中.exe的软件安装程序,用户可以使用它自行安装和管理Linux上的应用程序和系统工具; RPM软件包文件都是以.rpm为后缀,一般采用这样的命名格式:软件包名称 – 版本号 – 修正版 . 硬件平台 . rpm。 1.2 RPM命令的使用方法 查询:rpm {-q…

    2018-07-02
  • CentOS系统/boot/下的文件恢复

    如果不小心删除了/boot/下的所有文件,不知道恢复的具体步骤,请您看这里!

    2018-05-11
  • 第四周Linux小总结

    sed工具;用法: sed [option]… ‘script’ inputfile…常用选项:-n:不输出模式空间内容到屏幕,即不自动打印[root@localhost ~]# sed -n -e “2p” -e “6p” f1 (2;6代表处理第几行)-e: …

    Linux笔记 2018-04-22
  • 1

    1

    Linux笔记 2018-05-26