|
使用下面的格式通过正则表达式匹配出你想要查看的服务的当前状态。下面是使用 systemctl 命令查看 httpd 服务的状态。
# systemctl list-unit-files --type=service | grep httpdhttpd.service disabled
如何让指定的服务开机自启
使用下面格式的 systemctl 命令启用一个指定的服务。启用服务将会创建一个符号链接,如下可见:
# systemctl enable httpdCreated symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
运行下列命令再次确认服务是否被启用。
# systemctl is-enabled httpdenabled
如何禁用指定的服务
运行下面的命令禁用服务将会移除你启用服务时所创建的符号链接。
# systemctl disable httpdRemoved symlink /etc/systemd/system/multi-user.target.wants/httpd.service.
运行下面的命令再次确认服务是否被禁用。
# systemctl is-enabled httpddisabled
如何查看系统当前的运行级别
使用 systemctl 命令确认你系统当前的运行级别,runlevel 命令仍然可在 systemd 下工作,不过,运行级别对于 systemd 来说是一个历史遗留的概念。所以我建议你全部使用 systemctl 命令。
我们当前处于运行级别 3, 它等同于下面显示的 multi-user.target。
# systemctl list-units --type=targetUNIT LOAD ACTIVE SUB DESCRIPTIONbasic.target loaded active active Basic Systemcloud-config.target loaded active active Cloud-config availabilitycryptsetup.target loaded active active Local Encrypted Volumesgetty.target loaded active active Login Promptslocal-fs-pre.target loaded active active Local File Systems (Pre)local-fs.target loaded active active Local File Systemsmulti-user.target loaded active active Multi-User Systemnetwork-online.target loaded active active Network is Onlinenetwork-pre.target loaded active active Network (Pre)network.target loaded active active Networkpaths.target loaded active active Pathsremote-fs.target loaded active active Remote File Systemsslices.target loaded active active Slicessockets.target loaded active active Socketsswap.target loaded active active Swapsysinit.target loaded active active System Initializationtimers.target loaded active active Timers
(编辑:衢州站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|