{"id":3114,"date":"2019-06-29T10:15:01","date_gmt":"2019-06-29T02:15:01","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=3114"},"modified":"2022-05-12T17:05:38","modified_gmt":"2022-05-12T09:05:38","slug":"systemctl","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/systemctl","title":{"rendered":"systemctl\u547d\u4ee4 – \u7ba1\u7406\u7cfb\u7edf\u670d\u52a1"},"content":{"rendered":"\n

systemctl\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201dsystem control\u201c\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u7ba1\u7406\u7cfb\u7edf\u670d\u52a1\u3002\u4eceRHEL\/CentOS7\u7248\u672c\u4e4b\u540e\u521d\u59cb\u5316\u8fdb\u7a0b\u670d\u52a1init\u88ab\u66ff\u4ee3\u6210\u4e86systemd\u670d\u52a1\uff0csystemd\u521d\u59cb\u5316\u8fdb\u7a0b\u670d\u52a1\u7684\u7ba1\u7406\u662f\u901a\u8fc7systemctl\u547d\u4ee4\u5b8c\u6210\u7684\uff0c\u4ece\u529f\u80fd\u4e0a\u6db5\u76d6\u4e86\u4e4b\u524dservice\u3001chkconfig\u3001init\u3001setup\u7b49\u591a\u6761\u547d\u4ee4\u7684\u5927\u90e8\u5206\u529f\u80fd\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f<\/strong>\uff1asystemctl \u53c2\u6570 \u670d\u52a1<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n

start <\/td>\u542f\u52a8\u670d\u52a1<\/td><\/tr>
stop <\/td>\u505c\u6b62\u670d\u52a1<\/td><\/tr>
restart <\/td>\u91cd\u542f\u670d\u52a1<\/td><\/tr>
enable<\/td>\u4f7f\u67d0\u670d\u52a1\u5f00\u673a\u81ea\u542f<\/td><\/tr>
disable<\/td>\u5173\u95ed\u67d0\u670d\u52a1\u5f00\u673a\u81ea\u542f <\/td><\/tr>
status<\/td>\u67e5\u770b\u670d\u52a1\u72b6\u6001<\/td><\/tr>
list\u00a0-units\u00a0--type=service <\/td>\u5217\u4e3e\u6240\u6709\u5df2\u542f\u52a8\u670d\u52a1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u542f\u52a8\u6307\u5b9a\u7684\u670d\u52a1\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# systemctl start sshd<\/strong><\/pre>\n\n\n\n

\u505c\u6b62\u6307\u5b9a\u7684\u670d\u52a1\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# systemctl stop sshd<\/strong><\/pre>\n\n\n\n

\u91cd\u542f\u6307\u5b9a\u7684\u670d\u52a1\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# systemctl restart sshd<\/strong><\/pre>\n\n\n\n

\u67e5\u770b\u6307\u5b9a\u670d\u52a1\u7684\u8fd0\u884c\u72b6\u6001\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# systemctl status sshd<\/strong>\r\n\u25cf 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 2022-05-12 17:02:08 CST; 23s ago\r\n     Docs: man:sshd(8)\r\n           man:sshd_config(5)\r\n Main 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 12 17:02:08 linuxcool.com systemd[1]: Stopped OpenSSH server daemon.\r\nMay 12 17:02:08 linuxcool.com systemd[1]: Starting OpenSSH server daemon...\r\nMay 12 17:02:08 linuxcool.com sshd[3015]: Server listening on 0.0.0.0 port 22.\r\nMay 12 17:02:08 linuxcool.com sshd[3015]: Server listening on :: port 22.\r\nMay 12 17:02:08 linuxcool.com systemd[1]: Started OpenSSH server daemon.\r\nlines 1-16\/16 (END)\r<\/pre>\n\n\n\n

\u5c06\u6307\u5b9a\u7684\u670d\u52a1\u52a0\u5165\u5230\u5f00\u673a\u542f\u52a8\u9879\u4e2d\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# systemctl enable sshd<\/strong><\/pre>\n\n\n\n

\u5c06\u6307\u5b9a\u7684\u670d\u52a1\u4ece\u5f00\u673a\u542f\u52a8\u9879\u4e2d\u53d6\u6d88\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# systemctl disable sshd<\/strong><\/pre>\n\n\n\n

\u663e\u793a\u7cfb\u7edf\u4e2d\u6240\u6709\u5df2\u542f\u52a8\u7684\u670d\u52a1\u5217\u8868\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# systemctl list-units --type=service<\/strong>\r\n  UNIT                          LOAD   ACTIVE SUB     DESCRIPTION              \r\n  accounts-daemon.service       loaded active running Accounts Service         \r\n  atd.service                   loaded active running Job spooling tools       \r\n  auditd.service                loaded active running Security Auditing Service\r\n  avahi-daemon.service          loaded active running Avahi mDNS\/DNS-SD Stack  \r\n  bolt.service                  loaded active running Thunderbolt system service\r\n  colord.service                loaded active running Manage, Install and Gener>\r\n  crond.service                 loaded active running Command Scheduler        \r\n  cups.service                  loaded active running CUPS Scheduler         <\/pre>\n","protected":false},"excerpt":{"rendered":"

systemctl\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201dsystem control\u201c\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u7ba1\u7406\u7cfb\u7edf\u670d\u52a1\u3002\u4eceRHE […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3114"}],"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":26,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3114\/revisions"}],"predecessor-version":[{"id":9598,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3114\/revisions\/9598"}],"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}]}}