systemctl.cheat 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. % systemctl, service
  2. # Start service
  3. systemctl start <service_inactive>
  4. # Stop service
  5. systemctl stop <service_active>
  6. # Enable service
  7. systemctl enable <service_disabled>
  8. # Disable service
  9. systemctl disable <service_enabled>
  10. # Restart service
  11. systemctl restart <service>
  12. # Reload service
  13. systemctl reload <service_active>
  14. # Service status
  15. systemctl status <service>
  16. # List running services
  17. systemctl list-units --type=service --state=running
  18. # List enabled services
  19. systemctl list-unit-files --type=service --state=enabled
  20. # List disabled services
  21. systemctl list-unit-files --type=service --state=disabled
  22. $ service_inactive: systemctl list-units --type=service --state=inactive | awk '{print $1}' | grep .service | sed 's/.service$//'
  23. $ service_active: systemctl list-units --type=service --state=active | awk '{print $1}' | grep .service | sed 's/.service$//'
  24. $ service_enabled: systemctl list-unit-files --type=service --state=enabled | awk '{print $1}' | grep .service | sed 's/.service$//'
  25. $ service_disabled: systemctl list-unit-files --type=service --state=disabled | awk '{print $1}' | grep .service | sed 's/.service$//'
  26. $ service: systemctl list-units --type=service --all | awk '{print $1}' | grep .service | sed 's/.service$//'