SystemCTLCommands uses ConstantsTrait
Enumeration of common systemctl commands.
This class provides constants representing frequently used
systemctl
commands for managing the systemd system and service
manager on Linux. It can be used to standardize and centralize
command usage in scripts and applications.
Example:
use oihana\commands\enums\SystemCTLCommands;
// Start a service
shell_exec(SystemCTLCommands::SYSTEM_CTL_START . ' nginx');
// Check if a service is active
$isActive = trim(shell_exec(SystemCTLCommands::SYSTEM_CTL_IS_ACTIVE . ' nginx')) === 'active';
var_dump($isActive);
// List all running units
echo shell_exec(SystemCTLCommands::SYSTEM_CTL_LIST_UNITS);
Tags
Table of Contents
Constants
- SYSTEM_CTL = 'systemctl'
- The 'systemctl' cli command.
- SYSTEM_CTL_CAT = 'systemctl cat'
- Show backing files of one or more units.
- SYSTEM_CTL_DAEMON_RE_EXEC = 'systemctl daemon-reexec'
- Reloads systemd binary (rarely needed).
- SYSTEM_CTL_DAEMON_RELOAD = 'systemctl daemon-reload'
- Reloads unit files after changes (e.g., .service files).
- SYSTEM_CTL_DISABLE = 'systemctl disable'
- Disables autostart at boot.
- SYSTEM_CTL_ENABLE = 'systemctl enable'
- Enables the service to start on boot.
- SYSTEM_CTL_HELP = 'systemctl help'
- Show manual pages for one or more units, if available.
- SYSTEM_CTL_IS_ACTIVE = 'systemctl is-active'
- Checks if the service is running.
- SYSTEM_CTL_IS_ENABLED = 'systemctl is-enabled'
- Checks if the service is enabled to start on boot.
- SYSTEM_CTL_ISOLATE = 'systemctl isolate'
- Start the unit specified on the command line and its dependencies and stop all others.
- SYSTEM_CTL_KILL = 'systemctl kill'
- Send a signal to one or more processes of the unit.
- SYSTEM_CTL_LIST_DEPENDENCIES = 'systemctl list-dependencies'
- Shows required and wanted units of the specified unit.
- SYSTEM_CTL_LIST_SOCKETS = 'systemctl list-sockets'
- List socket units ordered by listening address.
- SYSTEM_CTL_LIST_TIMERS = 'systemctl list-timers'
- List timer units ordered by the time they elapse next.
- SYSTEM_CTL_LIST_UNITS = 'systemctl list-units'
- List known units (subject to limitations specified with -t).
- SYSTEM_CTL_MASK = 'systemctl mask'
- Completely disables a service (cannot start it).
- SYSTEM_CTL_RE_ENABLE = 'systemctl reenable'
- Rewrites symlinks for autostart.
- SYSTEM_CTL_RELOAD = 'systemctl reload'
- Asks all units listed on the command line to reload their configuration.
- SYSTEM_CTL_RESTART = 'systemctl restart'
- Restart one or more units specified on the command line.
- SYSTEM_CTL_SHOW = 'systemctl show'
- Show properties of one or more units, jobs, or the manager itself.
- SYSTEM_CTL_START = 'systemctl start'
- Start (activate) one or more units specified on the command line.
- SYSTEM_CTL_STATUS = 'systemctl status'
- Show terse runtime status information about one or more units, followed by most recent log data from the journal.
- SYSTEM_CTL_STOP = 'systemctl stop'
- Stop (deactivate) one or more units specified on the command line.
- SYSTEM_CTL_UNMASK = 'systemctl unmask'
- Reverses mask (restores ability to start).
Constants
SYSTEM_CTL
The 'systemctl' cli command.
public
mixed
SYSTEM_CTL
= 'systemctl'
SYSTEM_CTL_CAT
Show backing files of one or more units.
public
mixed
SYSTEM_CTL_CAT
= 'systemctl cat'
Prints the "fragment" and "drop-ins" (source files) of units. Each file is preceded by a comment which includes the file name.
SYSTEM_CTL_DAEMON_RE_EXEC
Reloads systemd binary (rarely needed).
public
mixed
SYSTEM_CTL_DAEMON_RE_EXEC
= 'systemctl daemon-reexec'
SYSTEM_CTL_DAEMON_RELOAD
Reloads unit files after changes (e.g., .service files).
public
mixed
SYSTEM_CTL_DAEMON_RELOAD
= 'systemctl daemon-reload'
SYSTEM_CTL_DISABLE
Disables autostart at boot.
public
mixed
SYSTEM_CTL_DISABLE
= 'systemctl disable'
SYSTEM_CTL_ENABLE
Enables the service to start on boot.
public
mixed
SYSTEM_CTL_ENABLE
= 'systemctl enable'
SYSTEM_CTL_HELP
Show manual pages for one or more units, if available.
public
mixed
SYSTEM_CTL_HELP
= 'systemctl help'
If a PID is given, the manual pages for the unit the process belongs to are shown.
SYSTEM_CTL_IS_ACTIVE
Checks if the service is running.
public
mixed
SYSTEM_CTL_IS_ACTIVE
= 'systemctl is-active'
SYSTEM_CTL_IS_ENABLED
Checks if the service is enabled to start on boot.
public
mixed
SYSTEM_CTL_IS_ENABLED
= 'systemctl is-enabled'
SYSTEM_CTL_ISOLATE
Start the unit specified on the command line and its dependencies and stop all others.
public
mixed
SYSTEM_CTL_ISOLATE
= 'systemctl isolate'
This is similar to changing the runlevel in a traditional init system. The isolate command will immediately stop processes that are not enabled in the new unit, possibly including the graphical environment or terminal you are currently using.
Note that this is allowed only on units where AllowIsolate= is enabled. See systemd.unit(5) for details.
SYSTEM_CTL_KILL
Send a signal to one or more processes of the unit.
public
mixed
SYSTEM_CTL_KILL
= 'systemctl kill'
Use --kill-who= to select which process to kill. Use --signal= to select the signal to send.
SYSTEM_CTL_LIST_DEPENDENCIES
Shows required and wanted units of the specified unit.
public
mixed
SYSTEM_CTL_LIST_DEPENDENCIES
= 'systemctl list-dependencies'
If no unit is specified, default.target is implied. Target units are recursively expanded. When --all is passed, all other units are recursively expanded as well.
SYSTEM_CTL_LIST_SOCKETS
List socket units ordered by listening address.
public
mixed
SYSTEM_CTL_LIST_SOCKETS
= 'systemctl list-sockets'
SYSTEM_CTL_LIST_TIMERS
List timer units ordered by the time they elapse next.
public
mixed
SYSTEM_CTL_LIST_TIMERS
= 'systemctl list-timers'
If one or more PATTERNs are specified, only units matching one of them are shown.
SYSTEM_CTL_LIST_UNITS
List known units (subject to limitations specified with -t).
public
mixed
SYSTEM_CTL_LIST_UNITS
= 'systemctl list-units'
If one or more PATTERNs are specified, only units matching one of them are shown. This is the default command.
SYSTEM_CTL_MASK
Completely disables a service (cannot start it).
public
mixed
SYSTEM_CTL_MASK
= 'systemctl mask'
SYSTEM_CTL_RE_ENABLE
Rewrites symlinks for autostart.
public
mixed
SYSTEM_CTL_RE_ENABLE
= 'systemctl reenable'
SYSTEM_CTL_RELOAD
Asks all units listed on the command line to reload their configuration.
public
mixed
SYSTEM_CTL_RELOAD
= 'systemctl reload'
Note that this will reload the service-specific configuration, not the unit configuration file of systemd.
If you want systemd to reload the configuration file of a unit, use the daemon-reload command. In other words: for the example case of Apache, this will reload Apache's httpd.conf in the web server, not the apache.service systemd unit file.
SYSTEM_CTL_RESTART
Restart one or more units specified on the command line.
public
mixed
SYSTEM_CTL_RESTART
= 'systemctl restart'
If the units are not running yet, they will be started.
SYSTEM_CTL_SHOW
Show properties of one or more units, jobs, or the manager itself.
public
mixed
SYSTEM_CTL_SHOW
= 'systemctl show'
If no argument is specified, properties of the manager will be shown. If a unit name is specified, properties of the unit is shown, and if a job id is specified, properties of the job is shown. By default, empty properties are suppressed.
Use --all to show those too. To select specific properties to show, use --property=.
This command is intended to be used whenever computer-parsable output is required.
Use status if you are looking for formatted human-readable output.
SYSTEM_CTL_START
Start (activate) one or more units specified on the command line.
public
mixed
SYSTEM_CTL_START
= 'systemctl start'
SYSTEM_CTL_STATUS
Show terse runtime status information about one or more units, followed by most recent log data from the journal.
public
mixed
SYSTEM_CTL_STATUS
= 'systemctl status'
If no units are specified, show system status. If combined with --all, also show the status of all units (subject to limitations specified with -t). If a PID is passed, show information about the unit the process belongs to.
SYSTEM_CTL_STOP
Stop (deactivate) one or more units specified on the command line.
public
mixed
SYSTEM_CTL_STOP
= 'systemctl stop'
SYSTEM_CTL_UNMASK
Reverses mask (restores ability to start).
public
mixed
SYSTEM_CTL_UNMASK
= 'systemctl unmask'