Skip to content

Instantly share code, notes, and snippets.

@rafaftahsin
Last active July 16, 2020 09:16
Show Gist options
  • Save rafaftahsin/1cf487e43b06f92fe6a31302b340cbf7 to your computer and use it in GitHub Desktop.
Save rafaftahsin/1cf487e43b06f92fe6a31302b340cbf7 to your computer and use it in GitHub Desktop.
# Not Completed Yet
--------------------------------------------------------------------------------
WORKING WITH SERVICE
--------------------------------------------------------------------------------
systemctl stop servicename # Stop a running service
systemctl start service #Start a service
systemctl restart service #Restart a running service
systemctl reload service #Reload all config files in service
systemctl status service #See if service is running/enabled
systemctl enable service #Enable a service to start on boot
systemctl disable service #Disable service--won’t start at boot
systemctl show service #Show properties of a service (or other unit)
systemctl -H host status network #Run any systemctl command remotely
--------------------------------------------------------------------------------
VIEW systemd INFORMATION
--------------------------------------------------------------------------------
systemctl list-dependencies #Show a unit’s dependencies
systemctl list-sockets #List sockets and what activates
systemctl list-jobs #View active systemd jobs
systemctl list-unit-files #See unit files and their states
systemctl list-units #Show if units are loaded/active
systemctl get-default #List default target (like run level
--------------------------------------------------------------------------------
CHANGING SYSTEM STATES
--------------------------------------------------------------------------------
systemctl reboot #Reboot the system (reboot.target)
systemctl poweroff #Power off the system (poweroff.target)
systemctl emergency #Put in emergency mode (emergency.target)
systemctl default #Back to default target (multi-user.target
--------------------------------------------------------------------------------
VIEWING LOG MESSAGES
--------------------------------------------------------------------------------
journalctl #Show all collected log messages
journalctl -u network.service #See network service messages
journalctl -f #Follow messages as they appear
journalctl -k #Show only kernel messages
### Need to add unit file options frome following
## Ref 1 : https://www.freedesktop.org/software/systemd/man/systemd.service.html
## Ref 2 : https://www.freedesktop.org/software/systemd/man/systemd.unit.html#
## Ref 3 : https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Unit_Files.html
### Reference
## Ref 1 : https://access.redhat.com/sites/default/files/attachments/rh_systemd_reference_card_0914_jcs_print_2.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment