官术网_书友最值得收藏!

Working with boot targets

We can work with boot targets using the systemctl command. We touched on systemctl earlier in this chapter. Let's use the Ubuntu distribution. We can check which target is currently the default and running in the shell in real time by doing the following:

philip@ubuntu:~$ systemctl get-default
graphical.target
philip@ubuntu:~$

From the preceding output, we can see that graphical.target is the default running target. Now, if we want to change between targets, we can use the systemctl command. Let's change to multi-user.target:

philip@ubuntu:~$ systemctl isolate multi-user.target

As soon as we press the Enter key, the system will ask us to authenticate:

We can also run systemctl to verify the status of multi-user.target:

We can return the system to the GUI environment by using the systemctl command:

Also, we can take a look at one of the targets to see its structure, using the systemctl command:

philip@ubuntu:~$ systemctl show network.target
Id=network.target
Names=network.target
WantedBy=networking.service systemd-networkd.service NetworkManager.service
Conflicts=shutdown.target
Before=network-online.target rc-local.service
After=NetworkManager.service network-pre.target systemd-networkd.service network
Documentation=man:systemd.special(7) http://www.freedesktop.org/wiki/Software/sy
Description=Network
 LoadState=loaded
ActiveState=active
SubState=active
FragmentPath=/lib/systemd/system/network.target
UnitFileState=static
UnitFilePreset=enabled
StateChangeTimestamp=Wed 2018-06-20 10:50:52 PDT
StateChangeTimestampMonotonic=18205063
InactiveExitTimestamp=Wed 2018-06-20 10:50:52 PDT
InactiveExitTimestampMonotonic=18205063
ActiveEnterTimestamp=Wed 2018-06-20 10:50:52 PDT
ActiveEnterTimestampMonotonic=18205063
ActiveExitTimestampMonotonic=0
InactiveEnterTimestampMonotonic=0
CanStart=no

From the preceding output, one of the key values is WantedBy. This tells us who relies on the network.target. We can see that NetworkManager.service relies on the network.target. There are also details regarding StateChangeTimestampDocumentation, LoadState, and Description, to name a few.

主站蜘蛛池模板: 吐鲁番市| 郴州市| 长沙县| 阳曲县| 茂名市| 佛教| 井冈山市| 石家庄市| 安庆市| 扶风县| 乐东| 东乌珠穆沁旗| 旌德县| 泉州市| 长阳| 兴海县| 噶尔县| 松潘县| 定陶县| 梅河口市| 延吉市| 上虞市| 广东省| 全南县| 昌平区| 资阳市| 平原县| 融水| 黄冈市| 龙江县| 九寨沟县| 济阳县| 和田县| 依兰县| 宣恩县| 循化| 尉犁县| 青浦区| 石阡县| 新竹县| 涟水县|