{"id":1715,"date":"2015-03-30T15:59:38","date_gmt":"2015-03-30T12:59:38","guid":{"rendered":"http:\/\/joseph.zikusooka.com\/?p=1715"},"modified":"2015-03-30T16:32:32","modified_gmt":"2015-03-30T13:32:32","slug":"use-systemd-in-linux-like-a-pro-a-cheat-sheet","status":"publish","type":"post","link":"https:\/\/joseph.zikusooka.com\/?p=1715","title":{"rendered":"Use systemd in Linux like a Pro &#8211; A cheat sheet"},"content":{"rendered":"<p>As systemd becomes the default method of handling services in all major Linux distributions, below are some quick and easy-to-remember commands that will make you look like a pro.<\/p>\n<p><strong>systemctl<\/strong><\/p>\n<ul>\n<li>check for all running units<br \/>\n<code>systemctl<\/code><br \/>\n<em>TIP: To show all units, including in-active ones:<\/em><br \/>\n<code>systemctl list-unit-files<\/code><\/li>\n<\/ul>\n<ul>\n<li>Check for failed units<br \/>\n<code>systemctl --failed<\/code><\/li>\n<\/ul>\n<ul>\n<li>Start, stop, restart units<br \/>\n<code>systemctl start postfix.service<\/code><br \/>\n<code>systemctl restart postfix.service<\/code><br \/>\n<code>systemctl stop postfix.service<\/code><\/li>\n<\/ul>\n<ul>\n<li>Check status of a specific unit<br \/>\n<code>systemctl status mysqld.service<\/code><br \/>\n<em>TIP: Use -l for detailed status<\/em><\/li>\n<\/ul>\n<ul>\n<li>Enable or disable services<br \/>\n<code>systemctl enable firewalld.service<\/code><br \/>\n<code>systemctl disable NetworkManager.service<br \/>\n<\/code><em>TIP: If you disable a service, and it still runs,<\/em><br \/>\n<code>systemctl mask NetworkManager.service<\/code><br \/>\n<em>Use &#8216;unmask&#8217; to restore it<\/em><\/li>\n<\/ul>\n<ul>\n<li>See if a specific unit is enabled<br \/>\n<code>systemctl is-enabled iptables.service<\/code><\/li>\n<\/ul>\n<ul>\n<li>Create a snapshot &#8211; useful for testing various targets<br \/>\n<code>systemctl snapshot example.snapshot<\/code><br \/>\n<em>TIP: To activate it:<\/em><br \/>\n<code>systemctl isolate example.snapshot<br \/>\n<\/code><\/li>\n<\/ul>\n<ul>\n<li>Reboot\/poweroff\/suspend your machine<br \/>\n<code>systemctl reboot <\/code><br \/>\n<code>systemctl poweroff<\/code><br \/>\n<code>systemctl suspend<\/code><\/li>\n<\/ul>\n<ul>\n<li>Change current target &#8211; i.e. runlevel<br \/>\n<code>systemctl isolate graphical.target<\/code><\/li>\n<\/ul>\n<ul>\n<li>To list current target<br \/>\n<code>systemctl list-units --type=target<\/code><\/li>\n<\/ul>\n<p><strong>systemd<\/strong><\/p>\n<ul>\n<li>See which units take a long time to start during boot up<br \/>\n<code>systemd-analyze blame<\/code><br \/>\n<em>TIP: You can plot the boot up using: <\/em><br \/>\n<code>systemd-analyze plot<\/code><\/li>\n<\/ul>\n<ul>\n<li>See when a unit started and how long it took<br \/>\n<code>systemd-analyze critical-chain<\/code><\/li>\n<\/ul>\n<p><strong>journalctl<\/strong><\/p>\n<ul>\n<li>Create a running log like &#8216;tail -f \/var\/log\/messages&#8217;<br \/>\n<code>journalctl -f -o cat --no-pager<\/code><\/li>\n<\/ul>\n<ul>\n<li>Running log for a specific unit<br \/>\n<code>journalctl -f -o cat --no-pager -u httpd.service<\/code><\/li>\n<\/ul>\n<ul>\n<li>See boot messages &#8211; like &#8216;dmesg&#8217;<br \/>\n<code>journalctl -b<\/code><\/li>\n<\/ul>\n<p style=\"padding-left: 30px;\">Manage remote systems:<br \/>\n<code>systemctl status sshd -H root@1.2.3.4<\/code><\/p>\n<p>For detailed instructions on these and more commands, <strong>man<\/strong> as always is your best friend.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As systemd becomes the default method of handling services in all major Linux distributions, below are some quick and easy-to-remember commands that will make you look like a pro. systemctl check for all running units systemctl TIP: To show all units, including in-active ones: systemctl list-unit-files Check for failed units systemctl &#8211;failed Start, stop, restart [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1715","post","type-post","status-publish","format-standard","hentry","category-tips"],"_links":{"self":[{"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=\/wp\/v2\/posts\/1715","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1715"}],"version-history":[{"count":3,"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=\/wp\/v2\/posts\/1715\/revisions"}],"predecessor-version":[{"id":1718,"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=\/wp\/v2\/posts\/1715\/revisions\/1718"}],"wp:attachment":[{"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1715"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1715"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1715"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}