How do i list all available system sockets on a linux os?
-
Note: This is for newer versions of linux. Linux meaning popular Linux Operating Systems.
What is the difference between --list-unit-files and --list-units?
list-unit-files [PATTERN...] List unit files installed on the system, in combination with their enablement state (as reported by is-enabled). If one or more PATTERNs are specified, only unit files whose name matches one of them are shown (patterns matching unit file system paths are not supported).
list-units [PATTERN...] List units that systemd currently has in memory. This includes units that are either referenced directly or through a dependency, units that are pinned by applications programmatically, or units that were active in the past and have failed. By default only units which are active, have pending jobs, or have failed are shown; this can be changed with option --all. If one or more PATTERNs are specified, only units matching one of them are shown. The units that are shown are additionally filtered by --type= and --state= if those options are specified.
$ systemctl list-unit-files --type=socket UNIT FILE STATE acpid.socket enabled apport-forward.socket enabled avahi-daemon.socket enabled cups.socket enabled dbus.socket static docker.socket enabled saned.socket disabled snapd.socket enabled ssh.socket disabled syslog.socket static systemd-fsckd.socket static systemd-initctl.socket static systemd-journald-audit.socket static systemd-journald-dev-log.socket static systemd-journald.socket static systemd-networkd.socket disabled systemd-rfkill.socket static systemd-udevd-control.socket static systemd-udevd-kernel.socket static uuidd.socket enabled 20 unit files listed.
$ systemctl list-units --type=socket UNIT LOAD ACTIVE SUB DESCRIPTION acpid.socket loaded active running ACPID Listen Socket avahi-daemon.socket loaded active running Avahi mDNS/DNS-SD Stack Activation Socket cups.socket loaded active running CUPS Scheduler dbus.socket loaded active running D-Bus System Message Bus Socket docker.socket loaded active running Docker Socket for the API snapd.socket loaded active running Socket activation for snappy daemon syslog.socket loaded active running Syslog Socket systemd-fsckd.socket loaded active listening fsck to fsckd communication Socket systemd-initctl.socket loaded active listening /dev/initctl Compatibility Named Pipe systemd-journald-audit.socket loaded active running Journal Audit Socket systemd-journald-dev-log.socket loaded active running Journal Socket (/dev/log) systemd-journald.socket loaded active running Journal Socket systemd-rfkill.socket loaded active listening Load/Save RF Kill Switch Status /dev/rfki systemd-udevd-control.socket loaded active running udev Control Socket systemd-udevd-kernel.socket loaded active running udev Kernel Socket uuidd.socket loaded active listening UUID daemon activation socket LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 16 loaded units listed. Pass --all to see loaded but inactive units, too.
As we are on the topic of sockets. The --list-sockets option:
list-sockets [PATTERN...] List socket units currently in memory, ordered by listening address. If one or more PATTERNs are specified, only socket units matching one of them are shown.
Here you can see the listening address and what service uses it.
$ systemctl list-sockets -all LISTEN UNIT ACTIVATES /dev/rfkill systemd-rfkill.socket systemd-rfkill.service /run/acpid.socket acpid.socket acpid.service /run/apport.socket apport-forward.socket /run/avahi-daemon/socket avahi-daemon.socket avahi-daemon.service /run/cups/cups.sock cups.socket cups.service /run/snapd-snap.socket snapd.socket snapd.service /run/snapd.socket snapd.socket snapd.service /run/systemd/fsck.progress systemd-fsckd.socket systemd-fsckd.service /run/systemd/initctl/fifo systemd-initctl.socket systemd-initctl.service /run/systemd/journal/dev-log systemd-journald-dev-log.socket systemd-journald.service /run/systemd/journal/socket systemd-journald.socket systemd-journald.service /run/systemd/journal/stdout systemd-journald.socket systemd-journald.service /run/systemd/journal/syslog syslog.socket rsyslog.service /run/udev/control systemd-udevd-control.socket systemd-udevd.service /run/uuidd/request uuidd.socket uuidd.service /var/run/dbus/system_bus_socket dbus.socket dbus.service /var/run/docker.sock docker.socket docker.service audit 1 systemd-journald-audit.socket systemd-journald.service kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service 19 sockets listed.
© Lightnetics 2024