Home Operation and Maintenance Linux Operation and Maintenance Detailed introduction to systemctl command in Linux

Detailed introduction to systemctl command in Linux

Mar 05, 2018 am 09:52 AM
linux introduce

Linux Systemctl is a collection of system management daemons, tools and libraries used to replace the System V, service and chkconfig commands. The initial process is mainly responsible for controlling the systemd system and service manager. Through Systemctl –help, you can see that the command is mainly divided into: querying or sending control commands to the systemd service, commands for management unit services, commands related to service files, commands related to tasks, environments, and snapshots, configuration reloading of systemd services, and system Commands related to powering on and off.

1. List all available units


# systemctl list-unit-files
Copy after login

2. List all running units


# systemctl list-units
Copy after login

3. List all failed units


# systemctl –failed
Copy after login

4. Check whether a certain unit (such as crond.service) is enabled


##

# systemctl is-enabled crond.service
Copy after login

5. List all Service


# systemctl list-unit-files –type=service
Copy after login

6. How to start, restart, stop, reload services and check the status of services (such as httpd.service) in Linux


# systemctl start httpd.service
# systemctl restart httpd.service
# systemctl stop httpd.service
# systemctl reload httpd.service
# systemctl status httpd.service
Copy after login

Note: When we use systemctl's start, restart, stop and reload commands, the terminal will not output anything, only the status command can Printout.

7. How to activate the service and enable or disable the service at boot (that is, the mysql.service service is automatically started when the system starts)


# systemctl is-active mysql.service
# systemctl enable mysql.service
# systemctl disable mysql.service
Copy after login

8. How to block (so that it cannot be started) or display services (such as ntpdate.service)


# systemctl mask ntpdate.service
ln -s ‘/dev/null”/etc/systemd/system/ntpdate.service'
# systemctl unmask ntpdate.service
rm ‘/etc/systemd/system/ntpdate.service'
Copy after login

9. Use the systemctl command to kill the service


# systemctl kill crond
Copy after login

10. List all system mount points


# systemctl list-unit-files –type=mount
Copy after login

11. Mount, unmount, remount, reload the system mount point and check the mount point status in the system


# systemctl start tmp.mount
# systemctl stop tmp.mount
# systemctl restart tmp.mount
# systemctl reload tmp.mount
# systemctl status tmp.mount
Copy after login

12. Activate, enable or disable mount points at startup (automatically mounted at system startup)


# systemctl is-active tmp.mount
# systemctl enable tmp.mount
# systemctl disable tmp.mount
Copy after login

13. Mask (so that it cannot be enabled) or visible mount points in Linux


# systemctl mask tmp.mount
ln -s ‘/dev/null”/etc/systemd/system/tmp.mount'
# systemctl unmask tmp.mount
rm ‘/etc/systemd/system/tmp.mount'
Copy after login

14. List all available system sockets


# systemctl list-unit-files –type=socket
Copy after login

15. Check all Configuration details


# systemctl show mysql
Copy after login

16. Get the dependency list of a service (httpd)


# systemctl list-dependencies httpd.service
Copy after login

17. Start rescue mode


# systemctl rescue
Copy after login

18. Enter emergency mode


# systemctl emergency
Copy after login

19. List the currently used runlevels


# systemctl get-default
Copy after login

20. Start running level 5, that is, graphics mode


# systemctl isolate runlevel5.target
Copy after login

or



# systemctl isolate graphical.target
Copy after login

21. Start running level 3, that is, multi-user mode (command line)


# systemctl isolate runlevel3.target
Copy after login

or



# systemctl isolate multiuser.target
Copy after login

22. Set multi-user mode or graphics mode as the default running level


# systemctl set-default runlevel3.target
# systemctl set-default runlevel5.target
Copy after login

23. Restart, stop, suspend, hibernate or put the system into hybrid sleep

##

# systemctl reboot
# systemctl halt
# systemctl suspend
# systemctl hibernate
# systemctl hybrid-sleep
Copy after login

For those who don’t know what run level is, here’s the explanation. Runlevel 0: Shut down the system

Runlevel 1: Rescue, maintenance mode
Runlevel 3: Multi-user, no graphical system
Runlevel 4: Multi-user, no graphical system
Runlevel 5: Multi-user , Graphical system
Runlevel 6: Shut down and restart the machine

The above is the detailed content of Detailed introduction to systemctl command in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What computer configuration is required for vscode What computer configuration is required for vscode Apr 15, 2025 pm 09:48 PM

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

vscode terminal usage tutorial vscode terminal usage tutorial Apr 15, 2025 pm 10:09 PM

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

vscode cannot install extension vscode cannot install extension Apr 15, 2025 pm 07:18 PM

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

Can vscode be used for mac Can vscode be used for mac Apr 15, 2025 pm 07:36 PM

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.

See all articles