After modifying the configuration file, you need to reload the configuration file, and then restart the related services.
# Reload configuration file $ sudo systemctl daemon-reload# Restart related services $ sudo systemctl restart foobar Boot service management
Boot start unit
systemctl enable test.service increase Soft link ln -s '/usr/lib/systemd/system/postfix.service' from /lib/systemd/system/to /etc/systemd/system/multi-user.target.wants/'/etc/systemd /system/multi-user.target.wants/test.service'Once the configuration file is modified, let SystemD reload the configuration file and restart it, otherwise the modification will not take effect.
$ sudo systemctl daemon-reload$ sudo systemctl restart httpd.serviceboot does not start unit
systemctl disable test.service delete /etc/systemd/system/multi-user.target Soft link under .wantsCheck if boot is enabled
systemctl is-enabled test.service #Query service is bootingsystemd view boot self-starting program
ls /Etc/systemd/system/multi-user.target.wants/View systemd unit loading and activity
systemctlDisplay unit failed to start
systemctl --failedView all units managed by systemd
systemctl list-unit-files Service Management
Start Service
systemctl start httpd.serviceClose Service
< Pre>systemctl stop httpd.serviceRestart Service
systemctl restart httpd.serviceReload
systemctl reload httpd.serviceView Status
Systemctl status httpd.service includes startup status, startup time, main process and related processes, related logs systemctls Ystemctl is Systemd's main command for managing systems.
# Restart the system $ sudo systemctl reboot# Shut down the system, cut off the power $ sudo systemctl poweroff # CPU stop working $ sudo systemctl halt # Suspend system $ sudo systemctl suspend # Let the system enter hibernation state $ sudo systemctl hibernate# let The system enters interactive hibernation state. sudo systemctl hybrid-sleep# Starts into rescue state (single-user state) $ sudo systemctl rescue systemctl list-units command to view all units of the current system.# List the running Unit$ systemctl list-units# List all Units, including $systemctl list-units not found in the configuration file or failed to start --all# List all units that are not running $ systemctl list-units --all --state=inactive# List all Unit#l.ctctlist list-units failed to load --failed# List all running units of type $systemctl list-units --type =service# Shows whether a Unit is running $ systemctl is-active application.service# Shows whether a Unit is in a startup failure state $ systemctl is-failed application.service# Shows whether a Unit service has a startup link established $ systemctl is-enabled application.service configuration block
[Unit] block is usually the first block of the configuration file, used to define the metadata of the Unit, and configure the relationship with other Units . Its main fields are as follows.
Description: Short description Documentation: Document address Requires: Other Units that the current Unit depends on. If they are not running, the current Unit will fail to start. Wants: Other units that match the current Unit, if they are not running, the current Unit Does not start failure BindsTo: Similar to Requires, if the specified unit exits, it will cause the current Unit to stop running Before: If the specified unit of the field is also started, then the After must be started after the current Unit: If the specified unit of the field To start, then you must start Conflicts before the current Unit: The Unit specified here cannot run Condition with the current Unit: the condition that the current Unit must run, otherwise it will not run Assert: the condition that the current Unit must meet, otherwise it will report Startup failed!!! Important
eg:After=network.target sshd-keygen.serviceAfter field: indicates that if network.target or sshd-keygen.service needs to be started, then the current .service should be in them Then start. Accordingly, there is a Before field that defines which services sshd.service should be started before. Note that the After and Before fields only refer to the startup sequence and do not involve dependencies.[Install] is usually the last block of the configuration file to define how to boot and whether to boot. Its main fields are as follows.
WantedBy: Its value is one or more Targets. The current Unit activation (enable) symbolic link will be placed in the /etc/systemd/system directory under the subdirectory of the Target name + .wants suffix. RequiredBy: Its value is one or more Targets. When the current Unit is activated, the symbolic link will be placed in the /etc/systemd/system directory under the Target name + .required suffix in the subdirectory. Alias: The current Unit can be used to start. Alias: When the current Unit is activated, other Unit[Service] blocks that are activated at the same time are used for Service configuration. Only Units of Service type have this block. Its main fields are as follows.
Type: Defines the behavior of the process at startup. It has the following values. Type=simple: default value, execute the command specified by ExecStart, start the main process Type=forking: create a child process from the parent process in the fork mode. After the creation, the parent process will immediately exit Type=oneshot: one-time process, Systemd will wait for the current service. Exit, and then continue to execute Type=dbus: The current service starts Type=notify through D-Bus: After the current service is started, Systemd will be notified, and then continue to execute Type=idle: If other tasks are executed, the current service is completed. ExecStart will be run: Command to start the current service ExecStartPre: Command ExecStartPost executed before starting the current service: ExecReload executed after starting the current service: ExecStop executed when restarting the current service ExecStop: ExecStopPost executed when the current service is stopped: Stop when The command executed after the service RestartSec: the number of seconds to automatically restart the current service interval. Restart: Defines the situation. Systemd will automatically restart the current service. Possible values include always (always restart), on-success, on-failure, on-abnormal , on-abort, on-watchdogTimeoutSec: define Systemd Wait before stopping the current service in seconds Environment: Specifies the environment variablefull field list Unit configuration file, please refer to the official documentation.
Log ManagementSystemd manages the startup log of all Units in a unified manner. The benefit is that you can view all logs (kernel logs and application logs) with just one command of journalctl. The configuration file for the log is /etc/systemd/journald.conf.
Command Introduction Shutdown, poweroff, reboot, halt, init can be shut down, approximate
The arping command can be used to test the connectivity between hosts on the LAN and test wh
Linux ubuntu12.04 Uninstall and install mysql
Ubuntu14.04 forgot the root password solution
CentOS6.4 yum command to install php5.2.17
Using forever to implement Node.js project on Linux
Linuxweb directory file full script
Ubuntu configuration apache2.4 speed limit function
Linux service configuration linux system routing configuration
How does Win7 delete system startup items? How to delete the system startup item
Where is the win8.1 device manager open? Win8.1 open three ways of device manager
Alipay face payment how to use Alipay face recognition function tutorial
Alloy equipment 5 phantom pain 108 branch how to trigger phantom pain 108 spur can not trigger
Win10 disable driver auto update tutorial
Ls -l | Wc -l command multiple statistics one line
Win10 system app store uninstallation method
Windows 10/Xbox One cross-platform linkage: feature introduction video
A trick to group the Windows desktop icon
How to solve the problem of no sound in WIN7 system HDMI connection TV