-
-
Save vins31/4a57a2d34c08c62ab46f1711685057f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-------------------------------------------------------------------------------- | |
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 | |
-------------------------------------------------------------------------------- | |
WORKING WITH <service> | |
-------------------------------------------------------------------------------- | |
systemctl stop <service> # 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 is-enabled <service> # Check whether a service is enabled | |
systemctl disable <service> # Disable <service> -- won’t start at boot | |
systemctl enable --now <service> # Enable and start in one go | |
systemctl disable --now <service> # Disable and stop in one go | |
systemctl show <service> # Show properties of a <service> (or other unit) | |
systemctl daemon-reload # After directly modifying/adding config files | |
systemctl reset-failed <service> # Remove unit from failed list (allow auto restart again) | |
-------------------------------------------------------------------------------- | |
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 | |
-------------------------------------------------------------------------------- | |
VIEWING LOG MESSAGES | |
-------------------------------------------------------------------------------- | |
journalctl # Show all collected log messages | |
journalctl -b # Print everything since boot | |
journalctl -e # Print last page of the journal | |
journalctl -u <service>. # See message of the specified unit | |
journalctl -f # Follow messages as they appear | |
journalctl -k # Show only kernel messages | |
journalctl --no-pager # Non-interactive mode | |
journalctl --disk-usage # Show space used by logs | |
journalctl --rotate # Force log rotation | |
journalctl --vacuum-size=100M # Remove logs until <100MB is used | |
journalctl --vacuum-time=2weeks # Remove logs older 2 weeks | |
### 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