---
title: "linux中/etc/init.d的作用"
author: "myeasyeye"
date: "2013-06-22T21:05:00Z"
tags: []
slug: "linux-etc-init-d"
draft: false
lastmod: "2013-09-11T21:52:35Z"
id: 1941024
url: "https://myeasyeye.iteye.com/blog/1941024"
---

/etc/init.d目录在Linux系统中可是大名鼎鼎。它只负责一件事情，但却涉及到全系统。它包含系统中各种服务的start/stop脚本，从acpid到x11-common，其重要性可见一斑。

init.d初始化脚本称之为SystemV风格初始化，是SystemV系统传统之一，后来成为一些Unix系统的共同特性的源头。值得一提的是，在/etc目录下可能还包含rc#.d目录，这也是SystemV风格，#为数字0到6，为系统的运行级别runlevel。可见SystemV风格影响深远。

init.d目录下脚本的执行方式为

*/etc/initi.d/commandOPTION*

command指服务的命令，比如bluetooth，networking，samba，ssh等等。OPTION指stop，start，reload，restart，force-reload。

比如重启SSH服务的命令为（执行这个目录下的脚本，需要root用户权限）：

$sudo/etc/init.d/sshrestart

好像service命令也是调用这里的服务么？

例如，停止SSH服务：servicesshstop

**service xxx 启动 /etc/init.d/ 目录下的xxx脚本**

**如：service vsftpd start 和/etc/init.d/vsftpd start 有同样的作用**