{"id":3114,"date":"2019-06-29T10:15:01","date_gmt":"2019-06-29T02:15:01","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=3114"},"modified":"2024-01-04T23:34:18","modified_gmt":"2024-01-04T15:34:18","slug":"systemctl","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/systemctl","title":{"rendered":"systemctl\u547d\u4ee4 &#8211; \u7ba1\u7406\u7cfb\u7edf\u670d\u52a1"},"content":{"rendered":"\n<p>systemctl\u547d\u4ee4\u6765\u81ea\u82f1\u6587\u8bcd\u7ec4system control\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7ba1\u7406\u7cfb\u7edf\u670d\u52a1\u3002\u4eceRHEL 7\/ CentOS 7\u7248\u672c\u8d77\uff0c\u521d\u59cb\u5316\u8fdb\u7a0b\u670d\u52a1init\u88ab\u66ff\u4ee3\u4e3asystemd\u670d\u52a1\uff0csystemd\u521d\u59cb\u5316\u8fdb\u7a0b\u670d\u52a1\u7684\u7ba1\u7406\u662f\u901a\u8fc7systemctl\u547d\u4ee4\u5b8c\u6210\u7684\uff0c\u8be5\u547d\u4ee4\u6db5\u76d6\u4e86service\u3001chkconfig\u3001init\u3001setup\u7b49\u591a\u4e2a\u547d\u4ee4\u7684\u5927\u90e8\u5206\u529f\u80fd\u3002<\/p>\n\n\n\n<p><strong>\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>systemctl \u53c2\u6570 \u52a8\u4f5c \u670d\u52a1\u540d<\/p>\n\n\n\n<p><strong>\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>-a<\/td><td>\u663e\u793a\u6240\u6709\u5355\u4f4d<\/td><td rowspan=\"6\">&nbsp;<\/td><td>-q<\/td><td>\u9759\u9ed8\u6267\u884c\u6a21\u5f0f<\/td><\/tr><tr><td>-f<\/td><td>\u8986\u76d6\u4efb\u4f55\u51b2\u7a81\u7684\u7b26\u53f7\u94fe\u63a5<\/td><td>-r<\/td><td>\u663e\u793a\u672c\u5730\u5bb9\u5668\u7684\u5355\u4f4d<\/td><\/tr><tr><td>-H<\/td><td>\u8bbe\u7f6e\u8981\u8fde\u63a5\u7684\u4e3b\u673a\u540d<\/td><td>-s<\/td><td>\u8bbe\u7f6e\u8981\u53d1\u9001\u7684\u8fdb\u7a0b\u4fe1\u53f7<\/td><\/tr><tr><td>-M<\/td><td>\u8bbe\u7f6e\u8981\u8fde\u63a5\u7684\u5bb9\u5668\u540d<\/td><td>-t<\/td><td>\u8bbe\u7f6e\u5355\u5143\u7c7b\u578b<\/td><\/tr><tr><td>-n<\/td><td>\u8bbe\u7f6e\u8981\u663e\u793a\u7684\u65e5\u5fd7\u884c\u6570<\/td><td>--help<\/td><td>\u663e\u793a\u5e2e\u52a9\u4fe1\u606f<\/td><\/tr><tr><td>-o<\/td><td>\u8bbe\u7f6e\u8981\u663e\u793a\u7684\u65e5\u5fd7\u683c\u5f0f<\/td><td>--version<\/td><td>\u663e\u793a\u7248\u672c\u4fe1\u606f<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>\u5e38\u7528\u52a8\u4f5c\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>start<\/td><td>\u542f\u52a8\u670d\u52a1<\/td><td rowspan=\"4\">&nbsp;<\/td><td>disable<\/td><td>\u53d6\u6d88\u670d\u52a1\u5f00\u673a\u81ea\u542f<\/td><\/tr><tr><td>stop<\/td><td>\u505c\u6b62\u670d\u52a1<\/td><td>status<\/td><td>\u67e5\u770b\u670d\u52a1\u72b6\u6001<\/td><\/tr><tr><td>restart<\/td><td>\u91cd\u542f\u670d\u52a1<\/td><td>list<\/td><td>\u663e\u793a\u6240\u6709\u5df2\u542f\u52a8\u670d\u52a1<\/td><\/tr><tr><td>enable<\/td><td>\u8bbe\u7f6e\u670d\u52a1\u5f00\u673a\u81ea\u542f<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>\u53c2\u8003\u793a\u4f8b<\/strong><\/p>\n\n\n\n<p>\u542f\u52a8\u6307\u5b9a\u7684\u670d\u52a1\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@linuxcool ~]# systemctl start sshd<\/pre>\n\n\n\n<p>\u505c\u6b62\u6307\u5b9a\u7684\u670d\u52a1\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@linuxcool ~]# systemctl stop sshd<\/pre>\n\n\n\n<p>\u91cd\u542f\u6307\u5b9a\u7684\u670d\u52a1\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@linuxcool ~]# systemctl restart sshd <\/pre>\n\n\n\n<p>\u5c06\u6307\u5b9a\u7684\u670d\u52a1\u52a0\u5165\u5230\u5f00\u673a\u542f\u52a8\u9879\u4e2d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@linuxcool ~]# systemctl enable sshd<\/pre>\n\n\n\n<p>\u67e5\u770b\u6307\u5b9a\u670d\u52a1\u7684\u8fd0\u884c\u72b6\u6001\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@linuxcool ~]# systemctl status sshd \r\n\u2022 sshd.service - OpenSSH server daemon \r\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/sshd.service; enabled; vendor preset> \r\n   Active: active (running) since Thu 2023-05-18 17:02:08 CST; 23s ago \r\n     Docs: man:sshd(8) \r\n           man:sshd_config(5) \r\nMain PID: 3015 (sshd) \r\n   Tasks: 1 (limit: 12391) \r\n  Memory: 1.5M \r\n  CGroup: \/system.slice\/sshd.service \r\n         \u2514\u25003015 \/usr\/sbin\/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-p> \r\n\r\nMay 18 17:02:08 linuxcool.com systemd[1]: Stopped OpenSSH server daemon. \r\nMay 18 17:02:08 linuxcool.com systemd[1]: Starting OpenSSH server daemon... \r\nMay 18 17:02:08 linuxcool.com sshd[3015]: Server listening on 0.0.0.0 port 22. \r\nMay 18 17:02:08 linuxcool.com sshd[3015]: Server listening on :: port 22. \r\nMay 18 17:02:08 linuxcool.com systemd[1]: Started OpenSSH server daemon. \r\nlines 1-16\/16 (END) \r<\/pre>\n\n\n\n<p>\u5c06\u6307\u5b9a\u7684\u670d\u52a1\u4ece\u5f00\u673a\u542f\u52a8\u9879\u4e2d\u53d6\u6d88\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@linuxcool ~]# systemctl disable sshd<\/pre>\n\n\n\n<p>\u663e\u793a\u7cfb\u7edf\u4e2d\u6240\u6709\u5df2\u542f\u52a8\u7684\u670d\u52a1\u5217\u8868\u4fe1\u606f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@linuxcool ~]# systemctl list-units --type=service \r\n  UNIT \t\t\t\t\t\tLOAD ACTIVE SUB DESCRIPTION \r\n  accounts-daemon.service \t\tloaded active running Accounts Service \r\n  atd.service \t\t\t\t\tloaded active running Job spooling tools \r\n  auditd.service \t\t\t\tloaded active running Security Auditing Service \r\n  avahi-daemon.service \t\t\tloaded active running Avahi mDNS\/DNS-SD Stack \r\n  bolt.service \t\t\t\t\tloaded active running Thunderbolt system service \r\n  colord.service \t\t\t\tloaded active running Manage, Install and Gener> \r\n  crond.service \t\t\t\tloaded active running Command Scheduler\r\n  cups.service \t\t\t\t\tloaded active running CUPS Scheduler\r    <\/pre>\n","protected":false},"excerpt":{"rendered":"<p>systemctl\u547d\u4ee4\u6765\u81ea\u82f1\u6587\u8bcd\u7ec4system control\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7ba1\u7406\u7cfb\u7edf\u670d\u52a1\u3002\u4eceRHEL 7\/  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-3114","post","type-post","status-publish","format-standard","hentry","category-system"],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=3114"}],"version-history":[{"count":31,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3114\/revisions"}],"predecessor-version":[{"id":17012,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3114\/revisions\/17012"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=3114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=3114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=3114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}