{"id":496,"date":"2016-05-02T16:18:44","date_gmt":"2016-05-02T16:18:44","guid":{"rendered":"http:\/\/b534ba68236ba543ae44b22bd110a1d6"},"modified":"2018-06-18T01:29:40","modified_gmt":"2018-06-17T17:29:40","slug":"systemctl","status":"publish","type":"post","link":"https:\/\/www.xiaobo.li\/notes\/archives\/496","title":{"rendered":"systemctl"},"content":{"rendered":"<p>systemd\u67e5\u770b\u5f00\u673a\u81ea\u542f\u52a8\u7684\u7a0b\u5e8f(\u76f8\u5f53\u4e8echkconfig --list)<\/p>\n<p>ll \/etc\/systemd\/system\/multi-user.target.wants\/<\/p>\n<p>&nbsp;<\/p>\n<p>\u8fd0\u884c\u4e00\u4e2a\u670d\u52a1\uff1a<\/p>\n<p>systemctl start network.service<\/p>\n<p>\u5173\u95ed\u7f51\u7edc\u670d\u52a1\uff1a<\/p>\n<p>systemctl stop network.service<\/p>\n<p>\u91cd\u542f\u7f51\u7edc\u670d\u52a1\uff1a<\/p>\n<p>systemctl restart network.service<\/p>\n<p>\u663e\u793a\u4e00\u4e2a\u670d\u52a1\uff08\u65e0\u8bba\u8fd0\u884c\u4e0e\u5426\uff09\u7684\u72b6\u6001\uff1a<\/p>\n<p>systemctl status network.service<\/p>\n<p>\u5728\u5f00\u673a\u65f6\u542f\u7528\u4e00\u4e2a\u670d\u52a1\uff1a<\/p>\n<p>systemctl enable network.service<\/p>\n<p>\u5728\u5f00\u673a\u65f6\u7981\u7528\u4e00\u4e2a\u670d\u52a1\uff1a<\/p>\n<p>systemctl disable network.service<\/p>\n<p>\u67e5\u770b\u670d\u52a1\u5f00\u673a\u662f\u5426\u542f\u52a8\uff1a<\/p>\n<p>systemctl is-enabled network.service<\/p>\n<p>&nbsp;<\/p>\n<p>\u5e38\u7528systemctl\u547d\u4ee4start,stop,restart,status,enable,disable,is-enabled,is-active\u3002<\/p>\n<p>&nbsp;<\/p>\n<h6>####################<\/h6>\n<p>1. \u5217\u51fa\u6240\u6709\u53ef\u7528\u5355\u5143<\/p>\n<p># systemctl list-unit-files<\/p>\n<p>2. \u5217\u51fa\u6240\u6709\u8fd0\u884c\u4e2d\u5355\u5143<\/p>\n<p># systemctl list-units<\/p>\n<p>3. \u5217\u51fa\u6240\u6709\u5931\u8d25\u5355\u5143<\/p>\n<p># systemctl \u2013failed<\/p>\n<p>4. \u68c0\u67e5\u67d0\u4e2a\u5355\u5143\uff08\u5982 crond.service\uff09\u662f\u5426\u542f\u7528<\/p>\n<p># systemctl is-enabledcrond.service<\/p>\n<p>5. \u5217\u51fa\u6240\u6709\u670d\u52a1<\/p>\n<p># systemctl list-unit-files \u2013type=service<\/p>\n<p>6. Linux\u4e2d\u5982\u4f55\u542f\u52a8\u3001\u91cd\u542f\u3001\u505c\u6b62\u3001\u91cd\u8f7d\u670d\u52a1\u4ee5\u53ca\u68c0\u67e5\u670d\u52a1\uff08\u5982 httpd.service\uff09\u72b6\u6001<\/p>\n<p># systemctl start httpd.service<\/p>\n<p># systemctl restart httpd.service<\/p>\n<p># systemctl stop httpd.service<\/p>\n<p># systemctl reload httpd.service<\/p>\n<p># systemctl status httpd.service<\/p>\n<p>\u6ce8\u610f\uff1a\u5f53\u6211\u4eec\u4f7f\u7528systemctl\u7684start\uff0crestart\uff0cstop\u548creload\u547d\u4ee4\u65f6\uff0c\u7ec8\u7aef\u4e0d\u4f1a\u8f93\u51fa\u4efb\u4f55\u5185\u5bb9\uff0c\u53ea\u6709status\u547d\u4ee4\u53ef\u4ee5\u6253\u5370\u8f93\u51fa\u3002<\/p>\n<p>7. \u5982\u4f55\u6fc0\u6d3b\u670d\u52a1\u5e76\u5728\u5f00\u673a\u65f6\u542f\u7528\u6216\u7981\u7528\u670d\u52a1\uff08\u5373\u7cfb\u7edf\u542f\u52a8\u65f6\u81ea\u52a8\u542f\u52a8mysql.service\u670d\u52a1\uff09<\/p>\n<p># systemctl is-active mysql.service<\/p>\n<p># systemctl enable mysql.service<\/p>\n<p># systemctl disable mysql.service<\/p>\n<p>8. \u5982\u4f55\u5c4f\u853d\uff08\u8ba9\u5b83\u4e0d\u80fd\u542f\u52a8\uff09\u6216\u663e\u793a\u670d\u52a1\uff08\u5982ntpdate.service\uff09<\/p>\n<p># systemctl mask ntpdate.service<\/p>\n<p>ln -s \u2018\/dev\/null\u201d\/etc\/systemd\/system\/ntpdate.service\u2019<\/p>\n<p># systemctl unmask ntpdate.service<\/p>\n<p>rm \u2018\/etc\/systemd\/system\/ntpdate.service\u2019<\/p>\n<p>9. \u4f7f\u7528systemctl\u547d\u4ee4\u6740\u6b7b\u670d\u52a1<\/p>\n<p># systemctl killcrond<\/p>\n<p>10. \u5217\u51fa\u6240\u6709\u7cfb\u7edf\u6302\u8f7d\u70b9<\/p>\n<p># systemctl list-unit-files \u2013type=mount<\/p>\n<p>11. \u6302\u8f7d\u3001\u5378\u8f7d\u3001\u91cd\u65b0\u6302\u8f7d\u3001\u91cd\u8f7d\u7cfb\u7edf\u6302\u8f7d\u70b9\u5e76\u68c0\u67e5\u7cfb\u7edf\u4e2d\u6302\u8f7d\u70b9\u72b6\u6001<\/p>\n<p># systemctl start tmp.mount<\/p>\n<p># systemctl stop tmp.mount<\/p>\n<p># systemctl restart tmp.mount<\/p>\n<p># systemctl reload tmp.mount<\/p>\n<p># systemctl status tmp.mount<\/p>\n<p>12. \u5728\u542f\u52a8\u65f6\u6fc0\u6d3b\u3001\u542f\u7528\u6216\u7981\u7528\u6302\u8f7d\u70b9\uff08\u7cfb\u7edf\u542f\u52a8\u65f6\u81ea\u52a8\u6302\u8f7d\uff09<\/p>\n<p># systemctl is-active tmp.mount<\/p>\n<p># systemctl enable tmp.mount<\/p>\n<p># systemctl disable tmp.mount<\/p>\n<p>13. \u5728Linux\u4e2d\u5c4f\u853d\uff08\u8ba9\u5b83\u4e0d\u80fd\u542f\u7528\uff09\u6216\u53ef\u89c1\u6302\u8f7d\u70b9<\/p>\n<p># systemctl mask tmp.mount<\/p>\n<p>ln -s \u2018\/dev\/null\u201d\/etc\/systemd\/system\/tmp.mount\u2019<\/p>\n<p># systemctl unmask tmp.mount<\/p>\n<p>rm \u2018\/etc\/systemd\/system\/tmp.mount\u2019<\/p>\n<p>14. \u5217\u51fa\u6240\u6709\u53ef\u7528\u7cfb\u7edf\u5957\u63a5\u53e3<\/p>\n<p># systemctl list-unit-files \u2013type=socket<\/p>\n<p>15. \u68c0\u67e5\u67d0\u4e2a\u670d\u52a1\u7684\u6240\u6709\u914d\u7f6e\u7ec6\u8282<\/p>\n<p># systemctl showmysql<\/p>\n<p>16. \u83b7\u53d6\u67d0\u4e2a\u670d\u52a1\uff08httpd\uff09\u7684\u4f9d\u8d56\u6027\u5217\u8868<\/p>\n<p># systemctl list-dependencies httpd.service<\/p>\n<p>17. \u542f\u52a8\u6551\u63f4\u6a21\u5f0f<\/p>\n<p># systemctl rescue<\/p>\n<p>18. \u8fdb\u5165\u7d27\u6025\u6a21\u5f0f<\/p>\n<p># systemctl emergency<\/p>\n<p>19. \u5217\u51fa\u5f53\u524d\u4f7f\u7528\u7684\u8fd0\u884c\u7b49\u7ea7<\/p>\n<p># systemctl get-default<\/p>\n<p>20. \u542f\u52a8\u8fd0\u884c\u7b49\u7ea75\uff0c\u5373\u56fe\u5f62\u6a21\u5f0f<\/p>\n<p># systemctl isolate runlevel5.target<\/p>\n<p>\u6216<\/p>\n<p># systemctl isolate graphical.target<\/p>\n<p>21. \u542f\u52a8\u8fd0\u884c\u7b49\u7ea73\uff0c\u5373\u591a\u7528\u6237\u6a21\u5f0f\uff08\u547d\u4ee4\u884c\uff09<\/p>\n<p># systemctl isolate runlevel3.target<\/p>\n<p>\u6216<\/p>\n<p># systemctl isolate multiuser.target<\/p>\n<p>22. \u8bbe\u7f6e\u591a\u7528\u6237\u6a21\u5f0f\u6216\u56fe\u5f62\u6a21\u5f0f\u4e3a\u9ed8\u8ba4\u8fd0\u884c\u7b49\u7ea7<\/p>\n<p># systemctl set-default runlevel3.target<\/p>\n<p># systemctl set-default runlevel5.target<\/p>\n<p>23. \u91cd\u542f\u3001\u505c\u6b62\u3001\u6302\u8d77\u3001\u4f11\u7720\u7cfb\u7edf\u6216\u4f7f\u7cfb\u7edf\u8fdb\u5165\u6df7\u5408\u7761\u7720<\/p>\n<p># systemctl reboot<\/p>\n<p># systemctl halt<\/p>\n<p># systemctl suspend<\/p>\n<p># systemctl hibernate<\/p>\n<p># systemctl hybrid-sleep<\/p>\n<p>\u5bf9\u4e8e\u4e0d\u77e5\u8fd0\u884c\u7b49\u7ea7\u4e3a\u4f55\u7269\u7684\u4eba\uff0c\u8bf4\u660e\u5982\u4e0b\u3002<\/p>\n<p>Runlevel 0 : \u5173\u95ed\u7cfb\u7edf<\/p>\n<p>Runlevel 1 : \u6551\u63f4\uff0c\u7ef4\u62a4\u6a21\u5f0f<\/p>\n<p>Runlevel 3 : \u591a\u7528\u6237\uff0c\u65e0\u56fe\u5f62\u7cfb\u7edf<\/p>\n<p>Runlevel 4 : \u591a\u7528\u6237\uff0c\u65e0\u56fe\u5f62\u7cfb\u7edf<\/p>\n<p>Runlevel 5 : \u591a\u7528\u6237\uff0c\u56fe\u5f62\u5316\u7cfb\u7edf<\/p>\n<p>Runlevel 6 : \u5173\u95ed\u5e76\u91cd\u542f\u673a\u5668<\/p>\n<p>&nbsp;<\/p>\n<p>...<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>systemd\u67e5\u770b\u5f00\u673a\u81ea\u542f\u52a8\u7684\u7a0b\u5e8f(\u76f8\u5f53\u4e8echkconfig --list) <\/p>\n<p>ll \/etc\/systemd\/system\/multi-user.target.wants\/ <\/p>\n<p>&nbsp;<\/p>\n<p>\u8fd0\u884c\u4e00\u4e2a\u670d\u52a1\uff1a<\/p>\n<p>\n\tsystemctl start network.service<\/p>\n<p> \u5173\u95ed\u7f51\u7edc\u670d\u52a1\uff1a<\/p>\n<p>\n\tsystemctl stop network.service<\/p>\n<p> \u91cd\u542f\u7f51\u7edc\u670d\u52a1\uff1a<\/p>\n<p>\n\tsystemctl restart network.service<\/p>\n<p>\n\t\u663e\u793a\u4e00\u4e2a\u670d\u52a1\uff08\u65e0\u8bba\u8fd0\u884c\u4e0e\u5426\uff09\u7684\u72b6\u6001\uff1a <\/p>\n<p>systemctl status network.service<\/p>\n<p>\n\t\u5728\u5f00\u673a\u65f6\u542f\u7528\u4e00\u4e2a\u670d\u52a1\uff1a <\/p>\n<p>systemctl en...<\/p>\n<p> <a href=\"https:\/\/www.xiaobo.li\/notes\/archives\/496\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[287],"tags":[],"class_list":["post-496","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/comments?post=496"}],"version-history":[{"count":0,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/496\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/media?parent=496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/categories?post=496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/tags?post=496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}