← 返回命令列表

Linux command

invoke-rc.d 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Start a service

sudo invoke-rc.d [service] start

Stop a service

sudo invoke-rc.d [service] stop

Restart a service

sudo invoke-rc.d [service] restart

Check service status

invoke-rc.d [service] status

Reload service configuration

sudo invoke-rc.d [service] reload

Query whether an action would be allowed

invoke-rc.d --query [service] start

说明

invoke-rc.d executes System V style init script actions on Debian-based systems. It provides a standard interface that respects runlevel constraints and local policies set by the system administrator via policy-rc.d. The tool checks /usr/sbin/policy-rc.d before executing actions. It is the recommended way to control services in package maintainer scripts, as it properly handles policy restrictions that may be in place (such as in chroot environments or containers).

参数

--quiet
Suppress warnings and informational messages.
--force
Try to run the init script regardless of policy and init script subsystem errors. Use in maintainer scripts is discouraged.
--try-anyway
Try to run the init script if a non-fatal error is detected.
--disclose-deny
Return status code 101 instead of 0 if the action is denied by the policy layer.
--query
Query what action would be taken without executing it. Returns status codes 100-106. Implies --disclose-deny and --no-fallback.
--no-fallback
Ignore any fallback action requests by the policy layer.
--help
Display help information.

FAQ

What is the invoke-rc.d command used for?

invoke-rc.d executes System V style init script actions on Debian-based systems. It provides a standard interface that respects runlevel constraints and local policies set by the system administrator via policy-rc.d. The tool checks /usr/sbin/policy-rc.d before executing actions. It is the recommended way to control services in package maintainer scripts, as it properly handles policy restrictions that may be in place (such as in chroot environments or containers).

How do I run a basic invoke-rc.d example?

Run `sudo invoke-rc.d [service] start` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --quiet do in invoke-rc.d?

Suppress warnings and informational messages.