diff --git a/src/rhcsa.md b/src/rhcsa.md index 0bd223e..18b57d4 100644 --- a/src/rhcsa.md +++ b/src/rhcsa.md @@ -240,7 +240,52 @@ atq # List all scheduled jobs atrm 1 # Remove the scheduled job with ID 1 ``` +### systemd +```bash +sudo systemctl start sshd # Start the sshd service +sudo systemctl stop sshd # Stop the sshd service +sudo systemctl restart sshd # Restart the sshd service + +sudo systemctl enable sshd # Enable the sshd service to start on boot +sudo systemctl disable sshd # Disable the sshd service from starting on boot +sudo systemctl status sshd # Check the status of the sshd service + +sudo systemctl daemon-reload # Reload the systemd daemon + +sudo systemctl mask sshd # Mask the sshd service +sudo systemctl unmask sshd # Unmask the sshd service +``` + +### systemd service and timer commands + +```bash +### Creating a service ### +sudo nano /etc/systemd/system/myapp.service +# [Unit] +# Description=My App +# After=network.target + +# [Service] +# ExecStart=/usr/bin/myapp + + +### Creating a timer ### +sudo nano /etc/systemd/system/myapp.timer +# [Unit] +# Description=My App Timer +# After=myapp.service + +# [Timer] +# OnBootSec=10min +# OnCalendar=daily + +### Tying the timer to the service ### +sudo systemctl link /etc/systemd/system/myapp.timer + +### Starting a service ### +sudo systemctl start myapp +```