偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

使用 Systemctl 命令來管理系統(tǒng)服務(wù)

系統(tǒng) Linux
Systemctl是systemd用于管理系統(tǒng)和管理服務(wù)的工具。許多現(xiàn)代Linux發(fā)行版,如Ubuntu、Debian、Fedora、Linux Mint、OpenSuSE、Redhat都采用systemd作為默認(rèn)的init系統(tǒng)。

[[379537]]

Systemctl是systemd用于管理系統(tǒng)和管理服務(wù)的工具。許多現(xiàn)代Linux發(fā)行版,如Ubuntu、Debian、Fedora、Linux Mint、OpenSuSE、Redhat都采用systemd作為默認(rèn)的init系統(tǒng)。 

使用systemctl,可以啟動、停止、重新加載、重啟服務(wù)、列出服務(wù)單元、檢查服務(wù)狀態(tài)、啟用/禁用服務(wù)、管理運行級別和電源管理。在本文中將展示如何在Linux中使用systemctl命令來管理systemd服務(wù)。

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

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

  1. [root@localhost ~]# systemctl start firewalld 

<以上代碼可復(fù)制粘貼,可往左滑>

與以前老版本的linux中的service命令相反,systemctl start命令不輸出任何內(nèi)容。

 

要停止服務(wù),請使用systemctl stop [service-name]。例如,停止firewalld服務(wù):

  1. [root@localhost ~]# systemctl stop firewalld 

<以上代碼可復(fù)制粘貼,可往左滑>

 

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

  1. [root@localhost ~]# systemctl restart firewalld 

<以上代碼可復(fù)制粘貼,可往左滑>

 

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

  1. [root@localhost ~]# systemctl reload sshd 

<以上代碼可復(fù)制粘貼,可往左滑>

 

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

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

  1. [root@localhost ~]# systemctl status firewalld 

<以上代碼可復(fù)制粘貼,可往左滑>

 

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

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

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

<以上代碼可復(fù)制粘貼,可往左滑>

 

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

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

<以上代碼可復(fù)制粘貼,可往左滑>

 

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

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

<以上代碼可復(fù)制粘貼,可往左滑>

 

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

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

  1. [root@localhost ~]# systemctl list-units 

<以上代碼可復(fù)制粘貼,可往左滑>

 

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

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

<以上代碼可復(fù)制粘貼,可往左滑>

 

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

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

  1. [root@localhost ~]# systemctl poweroff 

<以上代碼可復(fù)制粘貼,可往左滑>

重啟:

  1. [root@localhost ~]# systemctl reboot 

<以上代碼可復(fù)制粘貼,可往左滑>

系統(tǒng)休眠:

  1. [root@localhost ~]# systemctl hibernate 

<以上代碼可復(fù)制粘貼,可往左滑>

*使用systemclt管理遠(yuǎn)程系統(tǒng)

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

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

<以上代碼可復(fù)制粘貼,可往左滑>

 

-H選項,指定遠(yuǎn)程主機的用戶名和密碼。

*管理Targets

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

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

<以上代碼可復(fù)制粘貼,可往左滑>

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

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

<以上代碼可復(fù)制粘貼,可往左滑>

 

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

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

<以上代碼可復(fù)制粘貼,可往左滑>

 

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

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

<以上代碼可復(fù)制粘貼,可往左滑>

 

*systemd工具的其他命令

journalctl日志收集

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

  1. [root@localhost ~]# journalctl 

<以上代碼可復(fù)制粘貼,可往左滑>

 

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

  1. [root@localhost ~]# journalctl -b 

<以上代碼可復(fù)制粘貼,可往左滑>

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

  1. [root@localhost ~]# journalctl -f 

<以上代碼可復(fù)制粘貼,可往左滑>

 

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

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

<以上代碼可復(fù)制粘貼,可往左滑>

 

最后顯示系統(tǒng)啟動時間為8.901秒。查看服務(wù)的啟動時間:

  1. [root@localhost ~]# systemd-analyze blame 

<以上代碼可復(fù)制粘貼,可往左滑>

 hostnamectl命令

查看主機名稱:

  1. [root@localhost ~]# hostnamectl 

<以上代碼可復(fù)制粘貼,可往左滑>

 

*總 結(jié)在本文學(xué)習(xí)了systemctl命令來管理Linux發(fā)行版中的系統(tǒng)服務(wù)。希望對你們有所幫助。

本文轉(zhuǎn)載自微信公眾號「Linux就該這么學(xué)」,可以通過以下二維碼關(guān)注。轉(zhuǎn)載本文請聯(lián)系Linux就該這么學(xué)公眾號。 

 

責(zé)任編輯:武曉燕 來源: Linux就該這么學(xué)
相關(guān)推薦

2021-03-17 07:29:15

Systemctl 管理Linux

2020-11-04 18:53:07

Linuxsystemctl運維

2018-11-19 09:50:51

Linux命令操作系統(tǒng)

2020-01-18 18:41:13

GitGit服務(wù)器開源

2010-06-24 12:00:21

2010-08-06 09:05:17

2010-08-13 11:28:00

思科路由器

2015-07-31 10:20:13

Linux命令完全指南

2019-03-04 10:45:57

Linux Cockp系統(tǒng)性能命令

2017-10-26 12:50:14

云庫存管理云平臺工具

2021-03-19 09:30:22

Linuxkill命令 管理進(jìn)程

2012-06-29 17:46:41

BMCIT服務(wù)管理SaaS

2021-06-29 10:50:40

Linux.NET命令

2018-11-12 09:30:49

Linux命令文件管理器

2023-03-01 13:52:00

TerraformOpenStack運維

2023-12-08 12:04:32

命令Linux骨灰級

2010-05-25 13:47:53

MySQL 命令

2020-09-11 07:50:37

nmcli命令行網(wǎng)絡(luò)連接

2017-03-01 12:19:17

rsync Linux系統(tǒng)

2020-03-06 08:00:02

Multipass系統(tǒng)虛擬機
點贊
收藏

51CTO技術(shù)棧公眾號