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

What is the usage of systemctl and its grammar

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

Share

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

In this issue, Xiaobian will bring you about the usage of systemctl and what its syntax is. The article is rich in content and analyzed and described from a professional perspective. After reading this article, I hope you can gain something.

1. Determine if systemd and its version are installed

# systemctl -version

2. Determine the installation location of the binaries and library files for systemd and systemctl

# whereis systemd

# whereis systemctl

3. Determine if systemd is running

# ps -eaf | grep [s]ystemd

4. Analyze systemd startup process

# systemd-analyze

5. Analyze the time spent by each process at startup

# systemd-analyze blame

6. Analyze critical chain at startup

# systemd-analyze critical-chain

7. List all available units

# systemctl list-unit-files

8. List all active units

# systemctl list-units

9. List all failed units

# systemctl --failed

10. Determines whether a cell, such as nfs.service, is enabled

# systemctl is-enabled nfs.service

11. Determine if a unit or service is operational

# systemctl status nfs.service

12. List all services (both enabled and disabled)

# systemctl list-unit-files --type=service

13. Start, restart, stop, reload service and determine service (e.g. nfs.service) status

# systemctl start nfs.service

# systemctl restart nfs.service

# systemctl stop nfs.service

# systemctl reload nfs.service

# systemctl status nfs.service

- Note:

1) Systemctl start, restart, stop and reload commands, the terminal does not output any relevant information, but can be obtained through the status command.

14. Activate and configure services Autostart and Disable services

# systemctl is-active nfs.service

# systemctl enable nfs.service

# systemctl disable nfs.service

15. Shielding (prohibits any way to start the service, which is stronger than disabled) or unblocking the service

# systemctl mask nfs.service

# systemctl unmask nfs.service

16. Kill Service

# systemctl kill nfs

# systemctl status nfs

17. List all system mount points

# systemctl list-unit-files --type=mount

18. Mount, unmount, remount, reload system mount point, and determine system mount point state

# systemctl start tmp.mount

# systemctl stop tmp.mount

# systemctl restart tmp.mount

# systemctl reload tmp.mount

# systemctl status tmp.mount

19. Enable, enable (automount), or disable mount points at startup

# systemctl is-active tmp.mount

# systemctl enable tmp.mount

# systemctl disable tmp.mount

20. Mask (make it disabled) or unmask mount points

# systemctl mask tmp.mount

# systemctl unmask tmp.mount

21. List all available sockets

# systemctl list-unit-files --type=socket

22. Start, restart, stop, reload socket and confirm its status

# systemctl start cups.socket

# systemctl restart cups.socket

# systemctl stop cups.socket

# systemctl reload cups.socket

# systemctl status cups.socket

23. Enable socket at system startup and enable (auto-start) or disable socket

# systemctl is-active cups.socket

# systemctl enable cups.socket

# systemctl disable cups.socket

24. Mask (make it impossible to start) or unmask a socket

# systemctl mask cups.socket

# systemctl unmask cups.socket

25. Get CPU quota for a service

# systemctl show -p CPUShares nfs.service

26. Limit CPU quota for a service to 2000

# systemctl set-property nfs.service CPUShares=2000

# systemctl show -p CPUShares nfs.service

- Note:

1) When CPU quotas are set for a service, a directory (e.g. nfs.service) is created with the service name and contains a file called 90-CPUShares.conf, which contains information about CPUShare restrictions and can be viewed as follows:

# vi /etc/systemd/system/nfs.service.d/90-CPUShares.conf

27. Determine all configuration information for a service

# systemctl show nfs

28. Analyze the critical chain of a service

# systemd-analyze critical-chain nfs.service

29. Get dependencies for a service

# systemctl list-dependencies nfs.service

30. List control groups by rank

# systemd-cgls

31. List control groups by CPU, memory, input, and output

# systemd-cgtop

32. Enter system rescue mode.

# systemctl rescue

33. Emergency mode.

# systemctl emergency

34. Confirm current operating level

# systemctl get-default

35. Enter the appropriate operating level

--Graphic mode (5)

# systemctl isolate runlevel5.target

or

# systemctl isolate graphical.target

--Multi-user mode (3)

# systemctl isolate runlevel3.target

or

# systemctl isolate multiuser.target

36. Set default operating level

# systemctl set-default runlevel3.target

or

# systemctl set-default runlevel5.target

37. Restart, stop, suspend, hibernate, or enter hybrid sleep

# systemctl reboot

# systemctl halt

# systemctl suspend

# systemctl hibernate

# systemctl hybrid-sleep

- Note:

Runlevel 0 : Shut down the system.

Runlevel 1 : Rescue maintenance mode.

Runlevel 3 : Multi-user, no graphics mode.

Runlevel 4 : The system is not used and is reserved.

Runlevel 5 : Multi-user, graphical mode.

Runlevel 6 : Shut down and restart the system.

The above is what the systemctl usage and syntax are shared by Xiaobian. If there is a similar doubt, please refer to the above analysis for understanding. If you want to know more about it, please pay attention to the industry information channel.

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