国产欧美日韩第一页|日本一二三不卡视频|在线精品小视频,亚洲第一免费播放区,metcn人体亚洲一区,亚洲精品午夜视频

CentOS 7.X 中systemctl命令用法詳解

2016-11-27 12:52:59 14014

從linux系統(tǒng)版本centos 6.x到centos 7.x變化整體不大,不過還是有很多地方需要我們注意?,最為直觀的當(dāng)屬服務(wù)管理命令,之前centos 7.x之前的系統(tǒng)我們使用service和chkconfig來管理服務(wù)器,而到了centos 7.x 這個(gè)版本的linux中,systemctl 一個(gè)命令就搞定了,它集成了service和chkconfig 的功能于一身。這里今天簡單說明一下:


systemctl start *.service #啟動(dòng)?服務(wù)
systemctl stop *.service #停止某服務(wù)
systemctl restart *.service #重啟某服務(wù)
systemctl reload *.service #重載某服務(wù)配置文件
systemctl status *.service #查詢某服務(wù)運(yùn)行狀態(tài)
systemctl is-enabled *.service #查看某服務(wù)是否開機(jī)啟動(dòng)
systemctl enable *.service #設(shè)置開機(jī)啟動(dòng)
systemctl disable *.service #取消開機(jī)啟動(dòng)
systemctl –failed #查看啟動(dòng)失敗的服務(wù)

注:*指服務(wù)的名字,比如重啟、iptables,我?就會(huì)這樣操作:

[root@21yunwei network-scripts]# systemctl stop  iptables.service
[root@21yunwei network-scripts]# systemctl start iptables.service
[root@21yunwei network-scripts]# systemctl restart  iptables.service
[root@21yunwei network-scripts]# systemctl status  iptables.service
? iptables.service - IPv4 firewall with iptables
  Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled; vendor preset: disabled)
  Active: active (exited) since Fri 2016-06-17 17:52:05 CST; 16s ago
  Process: 48807 ExecStop=/usr/libexec/iptables/iptables.init stop (code=exited, status=0/SUCCESS)
  Process: 48870 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)
  Main PID: 48870 (code=exited, status=0/SUCCESS)
 
Jun 17 17:52:05 21yunwei systemd[1]: Starting IPv4 firewall with iptables...
Jun 17 17:52:05 21yunwei iptables.init[48870]: iptables: Applying firewall rules: [  OK  ]
Jun 17 17:52:05 21yunwei systemd[1]: Started IPv4 firewall with iptables.
[root@21yunwei network-scripts]# systemctl is-enabled iptables.service
enabled

補(bǔ)充一點(diǎn)小技巧:systemctl 默認(rèn)沒有服務(wù)器名補(bǔ)全,原因是最小化安裝沒有進(jìn)行安裝包bash-completion,需要執(zhí)行下邊命令后重新登錄系統(tǒng)就可以看到命令補(bǔ)全了。

yum install -y bash-completion


提交成功!非常感謝您的反饋,我們會(huì)繼續(xù)努力做到更好!

這條文檔是否有幫助解決問題?

非常抱歉未能幫助到您。為了給您提供更好的服務(wù),我們很需要您進(jìn)一步的反饋信息:

在文檔使用中是否遇到以下問題: