Linux服务器,服务管理–systemctl命令详解,设置开机自启动

Linux服务器,服务管理–systemctl命令详解,设置开机自启动
syetemclt就是service和chkconfig这两个命令的整合,在CentOS 7就开始被使用了。
摘要: 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

 

下面以nfs服务为例:

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.servicesudo systemctl stop firewalld.service          sudo systemctl disable firewalld.service

发布者:老王,转转请注明出处:https://u148.cn/252.html

(0)
老王的头像老王
上一篇 2021年 4月 27日 下午5:05
下一篇 2021年 5月 16日 下午7:11

相关推荐

  • Seafile加载资料库失败的处理方法记录

    之前公司内部用Seafile搭建了一个云盘,一直很正常,突然资料库架加载失败,特记录处理方式如下: 首先查看了磁盘状态,磁盘状态也没有满: C[root@localhost ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/centos-root 8.5G 3.1G 5.5G 36%…

    2021年 4月 27日
    5.2K00
  • Ubuntu(20.4)新装系统应该做的几件事

    一、配置root密码 二、修改主机名(hostname) 主机名(hostname)是在操作系统的安装过程中设置的,或者在创建虚拟机时动态分配给虚拟机的。 本指南说明了如何在Ubuntu 20.04上设置或更改主机名(hostname),而无需重新启动系统。 三、修改IP地址 默认的系统使用的是DHCP方式自动获取IP地址,如果有手动设置IP地址的需要,请参…

    2022年 5月 6日
    4.3K10
  • Windows 10 1903 SNMP离线安装方法【有附件】

    最近公司遇到一个项目,公司小伙伴遇到非互联网的Windows 10 1903的系统需要安装SNMP服务,死活不行。帮忙制作了这个包并且看到整个互联网都没人提供。所以在这里希望能帮到大家【压缩包里有文字+图文的使用说明】1.打开 C盘2.将Windows 10 1903 SNMP本文件夹内的 Windows目录拖入到 C盘根目录并覆盖3.将注册表1 和注册表2…

    2021年 4月 21日
    7.7K00
  • CentOS关机与重启详解

    Linux centos重启命令:1、reboot   普通重启2、shutdown -r now 立刻重启(root用户使用)3、shutdown -r 10 过10分钟自动重启(root用户使用)4、shutdown -r 20:35 在时间为20:35时候重启(root用户使用)如果是通过shutdown命令设置重启的话,可以用shutdown -c命…

    Linux 2021年 4月 27日
    4.0K00
  • Ubuntu20.X修改IP地址及主机名

    修改IP地址 ubuntu20.04修改IP地址,发现原来的修改/etc/network/interfaces文件内容的方法已经失效了,修改了/etc/network/interfaces的IP地址以后,也不生效,重启网络服务的/etc/init.d/目录下已经找不到networking的可执行程序了。搜索后发现从17.10开始,ubuntu已经改用netp…

    2022年 10月 19日
    4.3K00

发表回复

登录后才能评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信