π― What Youβll Learn
In this episode, youβll learn how to:
-
Start, stop, enable, and check services using
systemctl
-
Understand the difference between active and enabled
-
Troubleshoot service failures
-
Practice real RHCSA scenarios
π What Is systemctl
?
systemctl
is a command used to control services (also called units) on modern Linux systems using systemd.
β
RHEL 7 and above (including RHEL 8/9) use systemd as the init system.
β
For RHCSA, mastering systemctl
is a must.
π§ Real-World Analogy
Think of your Linux system as a factory, and services as machines.
-
systemctl start
= Turn the machine ON now π’ -
systemctl stop
= Turn the machine OFF now π΄ -
systemctl enable
= Tell it to automatically start every morning (at boot) β° -
systemctl disable
= Don't auto-start anymore -
systemctl status
= Check the machine's health β β
π§ͺ Common RHCSA Service Management Commands
Action | Command |
---|---|
Start a service now |
|
Stop a service |
|
Restart a service |
|
Reload (re-read config) |
|
Enable at boot |
|
Disable at boot |
|
Check status |
|
β Examples
Start and Enable Apache (httpd)
sudo systemctl start httpd
sudo systemctl enable httpd
Stop and Disable
sudo systemctl stop httpd
sudo systemctl disable httpd
Check Service Status
systemctl status httpd
Youβll see:
-
Active: active (running)
β -
Or
Active: inactive (dead)
β -
Or
failed
π₯ if something went wrong
π Check If Service Is Enabled at Boot
systemctl is-enabled httpd
Output:
-
enabled
= will start at boot π’ -
disabled
= wonβt start at boot π΄ -
static
= part of another unit, not standalone
π List All Running Services
systemctl list-units --type=service --state=running
π List All Services (Running or Not)
systemctl list-units --type=service
π List Failed Services
systemctl --failed
Very useful for troubleshooting!
π§ View Logs with journalctl
To see service logs (e.g., httpd):
journalctl -u httpd
Add
-xe
for detailed logs:
journalctl -xe
π Service File Location
Most unit files live in:
/usr/lib/systemd/system/
You can view or edit them (not usually needed for RHCSA).
π§ RHCSA Must-Know Scenario
-
Install a service:
sudo dnf install vsftpd
-
Start it:
sudo systemctl start vsftpd
-
Enable it at boot:
sudo systemctl enable vsftpd
-
Check status:
systemctl status vsftpd
-
Verify:
systemctl is-enabled vsftpd
β οΈ Troubleshooting Tips
Symptom | What to check |
---|---|
Service not running |
|
Logs not showing |
|
Wonβt start at boot | Check |
Service fails silently | Try |
β Summary: Know These Commands!
Purpose | Command |
---|---|
Start now |
|
Stop now |
|
Restart |
|
Enable at boot |
|
Disable at boot |
|
Check status |
|
View logs |
|
List services |
|