Linux启动服务的方式

本文介绍了Linux系统中两种启动服务的方法:service命令,它通过执行/etc/init.d目录下的程序;以及systemctl命令,它是针对systemd初始化系统的进程管理工具,旨在提升系统启动速度并优化进程并发启动。
摘要由CSDN通过智能技术生成

1、service命令

service命令其实是去/etc/init.d目录下,去执行相关程序

查看/etc/init.d目录下有哪些文件
[root@VM_0_11_centos init.d]# ll /etc/init.d/
total 40
-rw-r--r-- 1 root root 18281 Mar 29  2019 functions
-rwxr-xr-x 1 root root  4569 Mar 29  2019 netconsole
-rwxr-xr-x 1 root root  7923 Mar 29  2019 network
-rw-r--r-- 1 root root  1160 Oct 19 00:48 README
[root@VM_0_11_centos init.d]# 
查看脚本文件都有哪些命令
# See how we were called.
case "$1" in
start)
    [ "$EUID" != "0" ] && exit 4
    rc=0
    # IPv6 hook (pre IPv4 start)
    if [ -x /etc/sysconfig/network-scripts/init.ipv6-global ]; then
        /etc/sysconfig/network-scripts/init.ipv6-global start pre
    fi

    apply_sysctl

    #tell NM to reload its configuration
[root@VM_0_11_centos ~]# /etc/init.d/network start
Starting network (via systemctl):                          [  OK  ]
[root@VM_0_11_centos ~]# service restart network
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
[root@VM_0_11_centos ~]# 

2、systemctl命令

 systemd是Linux系统最新的初始化系统(init),作用是提高系统的启动速度,尽可能启动较少的进程,尽可能更多进程并发启动。
systemd对应的进程管理命令是systemctl

systemctl命令管理systemd的资源Unit

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值