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

相关推荐

  • 1

    1

    Linux笔记 2018-07-07
  • DNS服务及相关实验

    DNS(Domain Name Server,域名服务器)是进行域名(domain name)和与之相对应的IP地址 (IP address)转换的服务器。

    2018-06-02
  • 简单Linux脚本实现《鸡兔同笼》数学题的自动计算~!

    简单shell脚本计算《鸡兔同笼》数学名题

    2018-08-05
  • 在CentOS 7.3中创建本地yum源

    1.挂载系统光盘 1.1创建挂载文件 [root@centos7 ~]# mkdir /mnt/cdrom                          #创建文件 1.2挂载光驱 [root@centos7 ~]# mount /dev/cdrom /mnt/cdrom/              #挂载光驱  mount: /dev/sr0 is w…

    Linux笔记 2017-05-18
  • 第七周作业

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

    2018-05-02
  • 第二周总结

    反向单引号 ` `:执行能力强,可以执行命令 [等价于$()]单引号 ‘ ’:只显示字符双引号 “ ”:识别变量,不识别命令花括号{ }: 里面内容互相组合 打印重复字符串的简化形式echo file{1,3,5} 结果为:file1 file3 file5rm -f file{1,3,5} 删除file1 file3 file5echo file{1..1…

    Linux笔记 2018-07-29