In this exercise, you list installed service units and identify which services are currently enabled and active on a server.
Outcomes
List the installed service units.
Identify active and enabled services on the system.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start services-identify
Instructions
Use the ssh command to log in to the servera machine as the student user.
[student@workstation ~]$ ssh student@servera
[student@servera ~]$List all the installed service units on the servera machine.
[student@servera ~]$ systemctl list-units --type=service
UNIT LOAD ACTIVE SUB DESCRIPTION
atd.service loaded active running Deferred execution scheduler
auditd.service loaded active running Security Auditing Service
chronyd.service loaded active running NTP client/server
crond.service loaded active running Command Scheduler
dbus-broker.service loaded active running D-Bus System Message Bus
...output omitted...Press q to exit the command.
List all socket units, active and inactive, on the servera machine.
[student@servera ~]$ systemctl list-units --type=socket --all
UNIT LOAD ACTIVE SUB DESCRIPTION
dbus.socket loaded active running D-Bus System Message Bus Socket
dm-event.socket loaded active listening Device-mapper event daemon FIFOs
lvm2-lvmpolld.socket loaded active listening LVM2 poll daemon socket
...output omitted...
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.
13 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.Explore the status of the chronyd service.
You can use this service for network time protocol synchronization (NTP).
Display the status of the chronyd service.
Note the process ID of any active daemon.
[student@servera ~]$systemctl status chronyd● chronyd.service - NTP client/server Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2022-03-14 05:38:15 EDT; 1h 16min ago Docs: man:chronyd(8) man:chrony.conf(5) Process: 728 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)Main PID: 747 (chronyd)Tasks: 1 (limit: 10800) Memory: 3.7M CPU: 37ms CGroup: /system.slice/chronyd.service └─747 /usr/sbin/chronyd -F 2 Mar 14 05:38:15 servera.lab.example.com systemd[1]: Starting NTP client/server... Mar 14 05:38:15 servera.lab.example.com chronyd[747]: chronyd version 4.1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 +DEBUG) Mar 14 05:38:15 servera.lab.example.com chronyd[747]: commandkey directive is no longer supported Mar 14 05:38:15 servera.lab.example.com chronyd[747]: generatecommandkey directive is no longer supported Mar 14 05:38:15 servera.lab.example.com chronyd[747]: Frequency -11.870 +/- 1.025 ppm read from /var/lib/chrony/drift Mar 14 05:38:15 servera.lab.example.com chronyd[747]: Loaded seccomp filter (level 2) Mar 14 05:38:15 servera.lab.example.com systemd[1]: Started NTP client/server. Mar 14 05:38:23 servera.lab.example.com chronyd[747]: Selected source 172.25.254.254
Press q to exit the command.
Confirm that the chronyd daemon is running by using its process ID.
In the preceding command, the output of the process ID that is associated with the chronyd service is 747.
The process ID might differ on your system.
[student@servera ~]$ ps -p 747
PID TTY TIME CMD
747 ? 00:00:00 chronydExplore the status of the sshd service.
You can use this service for secure encrypted communication between systems.
Determine whether the sshd service is enabled to start at system boot.
[student@servera ~]$ systemctl is-enabled sshd
enabledDetermine whether the sshd service is active without displaying all the status information.
[student@servera ~]$ systemctl is-active sshd
activeDisplay the status of the sshd service.
[student@servera ~]$ systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-03-14 05:38:16 EDT; 1h 19min ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 784 (sshd)
Tasks: 1 (limit: 10800)
Memory: 6.7M
CPU: 82ms
CGroup: /system.slice/sshd.service
└─784 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"
Mar 14 05:38:16 servera.lab.example.com systemd[1]: Starting OpenSSH server daemon...
Mar 14 05:38:16 servera.lab.example.com sshd[784]: Server listening on 0.0.0.0 port 22.
Mar 14 05:38:16 servera.lab.example.com sshd[784]: Server listening on :: port 22.
Mar 14 05:38:16 servera.lab.example.com systemd[1]: Started OpenSSH server daemon.
Mar 14 06:51:36 servera.lab.example.com sshd[1090]: Accepted publickey for student from 172.25.250.9 port 53816 ssh2: RSA SHA256:M8ikhcEDm2tQ95Z0o7ZvufqEixCFCt+wowZLNzNlBT0
Mar 14 06:51:36 servera.lab.example.com sshd[1090]: pam_unix(sshd:session): session opened for user student(uid=1000) by (uid=0)Press q to exit the command.
List the enabled or disabled states of all service units.
[student@servera ~]$ systemctl list-unit-files --type=service
UNIT FILE STATE VENDOR PRESET
arp-ethers.service disabled disabled
atd.service enabled enabled
auditd.service enabled enabled
auth-rpcgss-module.service static -
autovt@.service alias -
blk-availability.service disabled disabled
bluetooth.service enabled enabled
chrony-wait.service disabled disabled
chronyd.service enabled enabled
...output omitted...Press q to exit the command.
Return to the workstation system as the student user.
[student@servera ~]$ exit
logout
Connection to servera closed.
[student@workstation]$This concludes the section.