11、linux系统之service

1.认识service命令

service network restart
# 这条命令实际上去找 /etc/init.d对应的二进制文件

2.Linux服务分类

  • RPM包默认安装的服务-通过service启动
  • 源码包安装的服务,通过启动脚本启动

3.服务启动总结

在这里插入图片描述

4.设置RPM包自启动的方法

什么是自启动:就是开机之后自动启动

4.1.查询已经安装的服务

chkconfig --list

4.2.使用chkconfig 命令开机启动

[root@localhost ~]# chkconfig [--level 运行级别] [独立服务名] [on|off] 
#选项: 
--level: 设定在哪个运行级别中开机自启动(on),或是关闭自启动(off)

[root@localhost ~]# chkconfig --level 2345 httpd on 
# 可以把--level 2345 省略掉

4.3.使用/etc/rc.d/rc.local文件开机启动

[root@localhost ~]# vi /etc/rc.d/rc.local #!/bin/sh #
# This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff.
touch /var/lock/subsys/local /etc/rc.d/init.d/httpd start

4.4.使用ntsysv开机启动

ntsysv

这个命令的操作是这样的:

  • 上下键:在不同服务之间移动
  • 空格键:选定或取消服务的自启动。就是在服务之前是否打入*
  • tab 键:在不同项目间切换
  • F1 键:显示服务的说明

猜你喜欢

转载自blog.csdn.net/weixin_43443216/article/details/107411844