日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
詳解systemctl命令使用實例

systemd是Linux系統(tǒng)最新的初始化系統(tǒng)(init),作用是提高系統(tǒng)的啟動速度,盡可能啟動較少的進程,盡可能更多進程并發(fā)啟動,systemd對應(yīng)的進程管理命令是systemctl,下面為大家詳細講解一下systemctl命令使用方法。

專注于為中小企業(yè)提供網(wǎng)站設(shè)計制作、網(wǎng)站建設(shè)服務(wù),電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)尉氏免費做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了成百上千家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實現(xiàn)規(guī)模擴充和轉(zhuǎn)變。

使用systemctl命令 Start/Stop/Restart/Reload 服務(wù)

使用systemctl啟動服務(wù)時,命令格式:systemctl start [service-name]。例如,啟動firewalld服務(wù):

[root@localhost ~]# systemctl start firewalld

與以前老版本的linux中的service命令相反,systemctl start命令不輸出任何內(nèi)容。 要停止服務(wù),請使用systemctl stop [service-name]。例如,停止firewalld服務(wù):

[root@localhost ~]# systemctl stop firewalld

要重新啟動服務(wù),請使用systemctl restart [service-name],例如:

[root@localhost ~]# systemctl restart firewalld

要重新加載服務(wù)的配置(例如ssh)而不重新啟動它,請使用systemctl reload [service-name],例如:

[root@localhost ~]# systemctl reload sshd

systemctl檢查服務(wù)狀態(tài)

為了查看服務(wù)是否正在運行,我們可以使用systemctl status [service-name]來查看。

[root@localhost ~]# systemctl status firewalld

檢查服務(wù)是否設(shè)置為開機啟動

要在引導(dǎo)時啟用服務(wù),請使用systemctl enable [service-name],例如:

[root@localhost ~]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

同樣,disable時取消引導(dǎo)時啟用服務(wù):

[root@localhost ~]# systemctl disable httpd.service

可以使用is-enabled選項檢查開機是否啟動該服務(wù),請運行:

[root@localhost ~]# systemctl is-enabled httpd.service

輸出的內(nèi)容enabled表示開機時啟動該服務(wù),disabled表示開機時不啟動該服務(wù)。

systemctl列出單元

要列出所有激活的單元,使用list-units選項。

[root@localhost ~]# systemctl list-units

要列出所有活動的服務(wù),請運行:

[root@localhost ~]# systemctl list-units -t service

使用systemctl重啟、關(guān)機系統(tǒng)

poweroff、shutdown命令一樣,systemctl命令可以關(guān)閉系統(tǒng),重啟或進入休眠狀態(tài)。

關(guān)機:

[root@localhost ~]# systemctl poweroff

重啟:

[root@localhost ~]# systemctl reboot

系統(tǒng)休眠:

[root@localhost ~]# systemctl hibernate

使用systemclt管理遠程系統(tǒng)

通常,上述所有systemctl命令都可以用于通過systemctl命令本身管理遠程主機。這將使用ssh與遠程主機進行通信。如下所示:

[root@localhost ~]# systemctl status httpd -H root@192.168.0.12

-H選項,指定遠程主機的用戶名和密碼。

管理Targets

Systemd具有Targets的概念,這些Targets的目的與sysVinit系統(tǒng)中的運行級別相似。sysVinit中的運行級別主要是數(shù)字(0,1,2,-6)。以下是sysVinit中的運行級別及其對應(yīng)的systemd中的target:

0   runlevel0.target, poweroff.target
1  runlevel1.target, rescue.target
2,3,4 runlevel2.target, runlevel3.target,runlevel4.target, multi-user.target
5   runlevel5.target, graphical.target
6   runlevel6.target, reboot.target

如果想要查看當前的運行級別,可以使用如下命令:

[root@localhost ~]# systemctl get-default
multi-user.target

設(shè)置默認的運行級別為graphical,命令如下:

[root@localhost ~]# systemctl set-default graphical.target
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.

想要列出所有激活的target,可以使用下面命令:

[root@localhost ~]# systemctl list-units -t target

systemd工具的其他命令

journalctl日志收集

systemd有自己的日志系統(tǒng),稱為journald。它替換了sysVinit中的syslogd。

[root@localhost ~]# journalctl

要查看所有引導(dǎo)消息,請運行命令journalctl -b

[root@localhost ~]# journalctl -b

以下命令實時跟蹤系統(tǒng)日志(類似于tail -f):

[root@localhost ~]# journalctl -f

查詢系統(tǒng)啟動過程的持續(xù)時間

[root@localhost ~]# systemd-analyze
Startup finished in 497ms (kernel) + 1.836s (initrd) + 6.567s (userspace) = 8.901s

最后顯示系統(tǒng)啟動時間為8.901秒。

查看服務(wù)的啟動時間:

[root@localhost ~]# systemd-analyze blame

hostnamectl命令

查看主機名稱:

[root@localhost ~]# hostnamectl


分享標題:詳解systemctl命令使用實例
網(wǎng)頁鏈接:http://www.5511xx.com/article/cogeope.html