Stopping legacy.service leaves legacy.socket listening and able to start the service on connection.
Stop the listener now and prevent it from returning at boot.
Which command is appropriate?
Disable and stop the .socket unit that owns the listener. Stopping only the service leaves the activation path available.
Detailed explanation
systemctl restart legacy.serviceIncorrect. It restarts the service and leaves the socket listener.
Incorrect. It restarts the service and leaves the socket listener.
systemctl disable --now legacy.serviceIncorrect. It handles the service but may leave legacy.socket able to reactivate it.
Incorrect. It handles the service but may leave legacy.socket able to reactivate it.
systemctl disable --now legacy.socketCorrect. It stops and disables the socket activation source.
Correct. It stops and disables the socket activation source.
systemctl reload legacy.socketIncorrect. reload rereads socket configuration without disabling the listener.
Incorrect. reload rereads socket configuration without disabling the listener.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' 'legacy.socket listens -> connection activates legacy.service' 'disable --now socket -> stop activation path'Expected result
legacy.socket listens -> connection activates legacy.service
disable --now socket -> stop activation pathKey points
- Stop the activation source
- .socket unit
- Service-only stop may be insufficient
Notes
- Environment: systemd socket activation対応表
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.