• linux关闭服务的方法


    本文介绍下,在linux下关闭服务的方法,主要学习chkconfig的用法,有需要的朋友参考下。
    先来看一个在linux关闭服务的例子,例如,要关闭sendmail服务,则可以按如下操作。

    例1,
     

    复制代码代码示例:
    [root@jbxue ~]# /etc/rc.d/init.d/sendmail stop  ← 关闭sendmail服务
    或[root@jbxue ~]# service sendmail stop  ← 关闭sendmail服务
    Shutting down sendmail: [ OK ]
    Shutting down sm-client: [ OK ]

    例2,
     

    复制代码代码示例:
    [root@jbxue ~]# chkconfig sendmail off  ← 关闭sendmail自启动
    [root@jbxue ~]# chkconfig --list sendmail  ← 确认sendmail自启动已被关闭(都为off就OK)
    sendmail 0:off 1:off 2:off 3:off 4:off 5:off 6:off

    具体示例,如下图:
    linux下配置服务启动

    图1
    linux下开启服务 chkconfig

    图2

    Linux下服务的启动和关闭管理有两种方式:
    1,直接执行服务启动/关闭脚本,即操作在/etc/init.d目录下的所有脚本,一般通过类似"/etc/init.d/sshd restart”的方式去重启服务;
    2,通过一个超级服务去管理一些常用网络服务,在Red Hat Linux/CentOS Linux下这个超级服务是xinetd,在xinetd这个服务下可以管理的服务有Telnet、vsftpd等,可以通过“/etc/init.d/xinetd restart”来完成对这些网络服务的重启。

    Linux下一般通过chkconfig命令来判断服务是开启或关闭状态:
     

    复制代码代码示例:
    [root@jbxue ~]$ /sbin/chkconfig --list sshd
    sshd            0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
    以上显示,sshd服务在Linux的2、3、4、5运行级出于开启状态,其他运行级出于关闭状态。

    在Linux运行级3、5下关闭sshd服务,执行命令:
     

    复制代码代码示例:
    [root@localhost ~]# /sbin/chkconfig --level 35 sshd off
    [root@localhost ~]# /sbin/chkconfig --list sshd
    sshd            0:关闭  1:关闭  2:启用  3:关闭  4:启用  5:关闭  6:关闭

    其他服务的开启和关闭与sshd类似。
    chkconfig还可以增加和删除相应的服务。
    有关chkconfig更详细的用法,请参考man chkconfig文档。
    本文出处参考:http://www.jbxue.com/LINUXjishu/10726.html

  • 相关阅读:
    SpringCloud Gateway使用实例
    Nacos服务注册与发现
    HashMap源码分析——put方法
    Volatile关键字——内存可见性
    Java的JIT编译器
    why spring?
    mysql 锁
    sql server 表变量和临时表
    mysql 存储过程
    mysql 截取字符串
  • 原文地址:https://www.cnblogs.com/linuxnotes/p/3330198.html
Copyright © 2020-2023  润新知