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日
下一篇 2021年 5月 16日

相关推荐

  • Win10安装JAVA1.8.0_60配置环境变量教程

    首先下载一个jdk,可以通过这个链接下载:https://pan.baidu.com/s/1aP6SdL8UQK_C2GvALLb6Wg也可以去官网下载:https://www.oracle.com/technetwork/java/javase/downloads/index.html 接下来就是安装,安装步骤省略。安装路径我们选择默认的,当然,我们也可也…

    2022年 4月 5日
    3.3K00
  • Ubuntu–安装ssh–方法/教程

    ubuntu默认没有安装ssh服务,如果通过ssh连接,需要自己手动安装ssh-server。 可以通过如下命令判断系统是否有安装ssh服务: 如上所示,表示还没有安装。可以通过apt安装,命令如下: 启动ssh服务 法1:systemctl命令 法2:原生ssh 查看是否启动 法1:systemctl命令 看到如下内容即表示成功 : Active: act…

    2022年 10月 18日
    3.2K00
  • Linux网卡配置文件参数注释

    [root@linux-node2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 TYPE=Ethernet # 设备类型 以太网 DEVICE=eth0 # 网卡设备名称 NAME=eth0 # 网卡连接名称 BOOTPROTO=static # 地址分配模式 启用静态IP地址 ONBOOT=yes #…

    2021年 4月 13日
    2.7K00
  • Linux操作系统基础

    Linux是一种自由和开放源码的操作系统,存在着许多不同的Linux版本,但它们都使用了Linux内核。Linux可安装在各种计算机硬件设备中,比如手机、平板电脑、路由器、台式计算机。 Linux介绍 Linux出现于1991年,是由芬兰赫尔辛基大学学生Linus Torvalds和后来加入的众多爱好者共同开发完成Linux特点 多用户,多任务,丰富的网络功…

    2021年 4月 12日
    2.3K00
  • 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日
    3.1K00

发表回复

登录后才能评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信