Debian GNU Linux服务列表的获取、服务的关闭/开启、服务在启动时是否自己主动执行的生效/失效

/*********************************************************************
 * Author  : Samson
 * Date    : 03/19/2015
 * Test platform:
 *              gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
 *              GNU bash, 4.3.11(1)-release (x86_64-pc-linux-gnu) 
 * *******************************************************************/

debian系统启动脚本

debian GNU/Linux使用SysV模块作为系统初始脚本。与RH一样,debian使用一个扩展的SysV模块,而slackware主要是基于BSD的,并为了使用SysV模块而写了几个方便的脚本。



定位SysV文件夹
debian GNU/Linux,与大多数使用SysV模块的系统一样。将相关的文件夹存放在/etc文件夹之下。也就是说,SysV文件夹/etc/init.d是脚本自 身,而/etc/rc1.d,/etc/rc2.d直到/etc/rc6.d是特殊执行级别的文件夹。

获取当前的服务列表:
service --status-all
root@ufo:/etc/rcS.d# service --status-all  
 [ + ]  acpid
 [ ? ]  alsa-utils
 [ - ]  anacron
 [ + ]  atd
 [ + ]  avahi-daemon
 [ ?

]  binfmt-support
 [ + ]  bluetooth
 [ - ]  bootlogs
 [ ?

]  bootmisc.sh
 [ ? ]  checkfs.sh
 [ ?

]  checkroot-bootclean.sh
 [ - ]  checkroot.sh
 [ - ]  console-setup
 [ + ]  cron
 [ + ]  cups
 [ + ]  dbus
 [ + ]  exim4
 [ + ]  gdm3
 [ ? ]  hdparm
 [ - ]  hostname.sh
 [ ? ]  hwclock.sh
 [ - ]  kbd
 [ - ]  keyboard-setup
 [ ? ]  killprocs
 [ ? ]  kmod
 [ + ]  minissdpd
 [ - ]  motd
 [ ? ]  mountall-bootclean.sh
 [ ?

]  mountall.sh
 [ ? ]  mountdevsubfs.sh
 [ ? ]  mountkernfs.sh
 [ ? ]  mountnfs-bootclean.sh
 [ ?

]  mountnfs.sh
 [ ?

]  mpt-statusd
 [ ? ]  mtab.sh
 [ + ]  network-manager
 [ ? ]  networking
 [ + ]  nfs-common
 [ ?

]  pppd-dns
 [ - ]  procps
 [ + ]  pulseaudio
 [ ? ]  rc.local
 [ - ]  rmnologin
 [ + ]  rpcbind
 [ + ]  rsyslog
 [ + ]  saned
 [ ? ]  sendsigs
 [ ? ]  speech-dispatcher
 [ - ]  ssh
 [ - ]  sudo
 [ + ]  udev
 [ ? ]  udev-mtab
 [ ? ]  umountfs
 [ ?

]  umountnfs.sh
 [ ?

]  umountroot
 [ - ]  unattended-upgrades
 [ - ]  urandom
 [ - ]  x11-common

当中[ + ]表示的是如今正在执行的服务项,[ - ]表示当前服务没有执行。

开启关闭服务项(以ssh服务为例):
root@ufo:/etc/rcS.d# service ssh start
[ ok ] Starting OpenBSD Secure Shell server: sshd.
root@ufo:/etc/rcS.d# service ssh stop
[ ok ] Stopping OpenBSD Secure Shell server: sshd.


也能够使用invoke-rc.d命令进行服务的运行等 。


使用服务项生效/失效:
update-rc.d [-n] name disable|enable [ S|2|3|4|5 ]



原文地址:https://www.cnblogs.com/yxysuanfa/p/6732057.html