Manage Sockets with Systemctl
You can also manage sockets using the Systemctl command.
To list all available system sockets, run the following command:
$ systemctl list-unit-files --type=socket
UNIT FILE STATE VENDOR PRESET
acpid.socket enabled enabled
avahi-daemon.socket enabled enabled
ssh.socket disabled enabled
cups.socket enabled enabled
dbus.socket static enabled
dm-event.socket enabled enabled
lvm2-lvmpolld.socket enabled enabled
saned.socket disabled enabled
snapd.socket enabled enabled
syslog.socket static disabled
systemd-coredump.socket static enabled
systemd-fsckd.socket static enabled
systemd-initctl.socket static enabled
To start the SSH socket, run the following command:
$ systemctl start ssh.socket
To stop the SSH socket, run the following command:
$ systemctl stop ssh.socket
To restart the SSH socket, run the following command:
$ systemctl restart ssh.socket
To check the status of the SSH socket, run the following command:
$ systemctl status ssh.socket
To enable and disable the SSH socket at boot time, run the following command:
$ systemctl enable ssh.socket $ systemctl disable ssh.socket
Control System Runlevels
How to start a system rescue mode.
# systemctl rescue
Broadcast message from root@tecmint on pts/0 (Wed 2015-04-29 11:31:18 IST):
The system is going down to rescue mode NOW!
How to enter into emergency mode.
$ systemctl emergency
Welcome to emergency mode! After logging in, type "journalctl -xb" to view
system logs, "systemctl reboot" to reboot, "systemctl default" to try again
to boot into default mode.
List current run levels in use.
$ systemctl get-default
multi-user.target
How to start Runlevel 5 aka graphical mode.
$ systemctl isolate runlevel5.target OR $ systemctl isolate graphical.target
How to start Runlevel 3 aka multiuser mode (command line).
$ systemctl isolate runlevel3.target OR $ systemctl isolate multiuser.target
How to set multiuser mode or graphical mode as default run level.
$ systemctl set-default runlevel3.target OR $ systemctl set-default runlevel5.target
How to reboot, halt, suspend, hibernate, or put a system in hybrid-sleep.
$ systemctl reboot $ systemctl halt $ systemctl suspend $ systemctl hibernate $ systemctl hybrid-sleep
For those who may not be aware of run levels and what it does.
[ads]
[box type=”info” align=”” class=”” width=””]
For those who may not be aware of run levels and what it does.
Runlevel 0 : Shut down and Power off the system.
Runlevel 1 : Rescue?Maintainance Mode.
Runlevel 3 : multiuser, no-graphic system.
Runlevel 4 : multiuser, no-graphic system.
Runlevel 5 : multiuser, graphical system.
Runlevel 6 : Shutdown and Reboot the machine.[/box]
Conclusion
In the above guide, you learned how to manage and control systemd service on Linux. I hope this will helps you to interact with and control your systemd instance. Feel free to ask me if you have any questions.
See also: How to Kill a Process in Linux