Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use systemd target Command in Linux

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use the systemd target command in Linux". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "how to use the systemd target command in Linux" together!

(1) How do you know which process services a target requires?

For example, you might want to find out which services are enabled for the target unit multi-user.target by using the following command:

The code is as follows:

$systemctlshow-p"Wants"multi-user.target

Wants=rc-local.serviceavahi-daemon.servicerpcbind.serviceNetworkManager.serviceacpid.servicedbus.serviceatd.servicecrond.serviceauditd.servicentpd.serviceudisks.servicebluetooth.serviceorg.cups.cupsd.servicewpa_supplicant.servicegetty.targetmodem-manager.serviceportreserve.serviceabrtd.serviceyum-updatesd.serviceupowerd.servicetest-first.servicepcscd.servicersyslog.servicehaldaemon.serviceremote-fs.targetplymouth-quit.servicesystemd-update-utmp-runlevel.servicesendmail.servicelvm2-monitor.servicecpuspeed.serviceudev-post.servicemdmonitor.serviceiscsid.servicelivesys.servicelivesys-late.serviceirqbalance.serviceiscsi.service

In addition to Wants, you can view various forms of dependency and dependent information: Wanted By, Requires, RequiredBy, Conflicts, Conflicted By, Before, After.

(2) Target and operation level

Prior to RHEL7, runlevels were used to represent specific modes of operation. Operational levels are defined as seven levels, represented by the numbers 0 to 6, each of which can launch specific services. RHEL7 uses target substitution to run the basics.

systemd target is described using a target unit file extension.target, whose sole goal is to organize other systemd unit files together through a chain of dependencies. For example, graphical.target unit, used to start a graphics session, systemd starts services like GNOME display management (gdm.service), account service (axxxounts-daemon), and activates multi-user.target unit. A similar multi-user.target unit starts the essential NetworkManager.service, dbus.service services and activates the basic.target unit.

RHEL7 predefines some targets that are more or less different from previous run-levels. For compatibility, systemd also provides some run-level targets mapped to SysV init. The specific corresponding information is as follows:

0runlevel0.target,poweroff.target Shut down the system.

1runlevel1.target,rescue.target Enter rescue mode.

2runlevel2.target,multi-user.target Enter the non-graphical multi-user mode.

3runlevel3.target,multi-user.target Enter the non-graphical multi-user mode.

4runlevel4.target,multi-user.target Enter the non-graphical multi-user mode.

5runlevel5.target,graphical.target Multi-user access to graphical interfaces.

6runlevel6.target,reboot.target Restart your system.

(3) Target management

1) Use the following command to view currently available targets:

The code is as follows:

systemctl list-units --type target

To change the current running base, use the following command:

The code is as follows:

systemctl isolate name.target

2) Modify the default operation level

Use the systemctl get-default command to get the default runlevel:

The code is as follows:

[root@localhost~]#systemctlget-default

multi-user.target

Use systemctl set-default name.target to modify the default run base

The code is as follows:

[root@localhost~]#systemctlset-defaultgraphical.target

rm'/etc/systemd/system/default.target'

ln-s'/usr/lib/systemd/system/graphical.target''/etc/systemd/system/default.target'

3) Rescue mode and emergency mode

Use systemctl rescue to enter rescue mode. If you can't even enter rescue mode, you can enter emergency mode:

The code is as follows:

systtmctl emergency

Emergency mode goes into making the system environment small in order to repair the system. Emergency mode root directory is mounted read-only, no network is activated, only few services are started, and the root password is required to enter emergency mode.

Thank you for reading, the above is the "Linux systemd target command use method" content, after the study of this article, I believe we have a deeper understanding of the Linux systemd target command use method, the specific use of the situation also needs to be verified. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report