Tri*_*onX 165
快速回答是:这取决于您的init
系统。
长答案是:对于当前版本的 Ubuntu,您可能混合使用了Upstart和SystemV。15.04“Vivid Vervet”(以及其他 Linux 发行版,如 RHEL/CentOS 7)之后的较新版本的 Ubuntu 正在转向使用SystemD。
列出所有服务:
sudo initctl list
Run Code Online (Sandbox Code Playgroud)
要列出所有 Upstart 服务并initctl show-config
在其上运行,此单行代码可能会有所帮助:
sudo initctl list | awk '{ print $1 }' | xargs -n1 initctl show-config
Run Code Online (Sandbox Code Playgroud)
列出所有服务:
sudo service --status-all
Run Code Online (Sandbox Code Playgroud)
或者:
# for init scripts:
ls /etc/init.d/
# for runlevel symlinks:
ls /etc/rc*.d/
Run Code Online (Sandbox Code Playgroud)
列出所有服务:
sudo systemctl list-unit-files --type=service
Run Code Online (Sandbox Code Playgroud)
或者:
ls /lib/systemd/system/*.service /etc/systemd/system/*.service
Run Code Online (Sandbox Code Playgroud)
Sco*_*ott 114
您可以简单地使用initctl list
shell 命令来列出内容/etc/init
而不是建议的dbus-send
命令。
Jer*_*err 13
在/etc/init.d
和/etc/rc.*
目录已被“取代upstart
”初始化工具。虽然这些目录中的脚本会按预期执行,但在 init 上运行东西的新方法是由文件中定义的/etc/init/
你可以通过 dbus 查询 upstart 列出所有的 upstart 工作:
dbus-send --print-reply --system --dest=com.ubuntu.Upstart \
/com/ubuntu/Upstart com.ubuntu.Upstart0_6.GetAllJobs
Run Code Online (Sandbox Code Playgroud)
您可能需要更改0_6
以反映您拥有的暴发户版本。此命令适用于我的 lucid 安装。
小智 12
如果您想要一个很好的服务图形表示和启动所需的时间,请尝试:
apt-get install bootchart
Run Code Online (Sandbox Code Playgroud)
小智 11
Id 用于initctl show-config <servicename>
真正获取有关何时/是否在启动期间启动服务的详细信息。
像这样:
$ initctl show-config myservice
myservice
start on runlevel [2345]
stop on runlevel [!2345]
Run Code Online (Sandbox Code Playgroud)
或者对于 NFS4 idmap-daemon:
$ initctl show-config idmapd
idmapd
start on (local-filesystems or mounting TYPE=nfs4)
stop on runlevel [06]
Run Code Online (Sandbox Code Playgroud)
chkconfig 仅适用于基于 RedHat 的系统恕我直言。
App*_*yGG 11
对于 Ubuntu 18.04 使用:
systemctl list-units --type=service
代替 :
initctl
从 Ubuntu 16.04 开始,initctl
已被systemd
.
https://www.linuxtricks.fr/wiki/systemd-les-commandes-essentielles (FR_fr)
(如果它可以帮助@sanjay-manohar)
在 12.04 上,我们可以使用:
sudo apt-get install chkconfig
chkconfig --list
Run Code Online (Sandbox Code Playgroud)
示例输出:
acpi-support 0:off 1:off 2:on 3:on 4:on 5:on 6:off
acpid 0:off 1:off 2:off 3:off 4:off 5:off 6:off
apparmor 0:off 1:off 2:off 3:off 4:off 5:off 6:off S:on
Run Code Online (Sandbox Code Playgroud)
除了以下系统服务和脚本之外:
/etc/init.d/
/lib/systemd/system/
/etc/systemd/system/
可能还有自动启动应用程序,例如:
find / -name "*autostart*"
ls -1 "/etc/xdg/autostart" "/home/$USER/.config/autostart" "/usr/share/gdm/autostart" "/usr/share/gnome/autostart"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
377378 次 |
最近记录: |