首页
/
每日頭條
/
生活
/
linux系統入門基礎知識摘要
linux系統入門基礎知識摘要
更新时间:2024-05-08 09:05:16

Systemd在系統中是一個用戶級的應用程序,包含一個完整的軟件包,配置文件位于/etc/systemd目錄下。配置工具命令位于/bin,/sbin目錄下,備用配置文件位于/lib/systemd目錄下,可以通過命令"rpm -ql systemd"查看所有文件的安裝目錄。

systemd提供了一個非常強大的命令行工具systemctl。大部分運維小夥伴可能非常熟悉sysvinit的服務管理模式,比如service、chkconfig命令。而systemd也能完成同樣的管理任務,可以吧systemctl看作service和chkconfig的組合體。查查看、啟動、停止、重啟、啟用和禁用系統服務,都可以通過systemctl命令來實現。為了向後兼容,service命令仍可用,不過它會重定向所有命令到新的syatemctl工具。

一、啟動、停止、重啟服務

使用systemctl命令重啟一個服務,可以使用如下命令

systemctl start httpd.service

這就啟動了httpd服務,要停掉它,需要以root身份使用如下命令

systemctl stop httpd.service

要重啟httpd服務,可以使用restart選項。它表示如果服務在運行中,則重啟;如果服務不在運行中則啟動。也可以使用try-restart選項,它隻會在服務已經運行的狀态下重啟服務。同事也可以使用reload選項,它會重新加載配置文件。命令如下:

systemctl restart httpd.service

systemctl try-restart httpd.service

systemctl reload httpd.service

二、查看、禁止、啟用服務

通過systemctl命令可以啟用、禁用服務,以控制開機服務啟動,可以使用enable/disable選項來控制一個服務是否開機啟動,命令如下:

systemctl enable httpd.service

這樣就打開了httpd服務的開機自啟動功能。要關閉httpd服務,可以使用如下命令:

systemctl disable httpd.service

要查看一個服務的運行狀态,可以使用systemctl命令的status選項,執行過程如下所示

linux系統入門基礎知識摘要(循序漸進學習Linux5)1

三、systemd和sysvinit常見操作對比

描述

SysVinit

Systemd

啟動服務

service example start

systemctl start example

停止服務

service example stop

systemctl stop example

重新啟動服務

service example restart

systemctl restart example

重新加載服務配置文件

service example reload

systemctl reload example

查看服務狀态

service example status

systemctl status example

系統啟動時啟用服務

chkconfig example on

systemctl enable example

系統啟動時禁用服務

chkconfig example off

systemctl disable example

打印服務列表

chkconfig --list

systemctl list-unit-files --type=service

systemd低安源管理命令

systemctl命令

含義

systemctl poweroff

關閉系統

systemctl reboot

重啟系統

systemctl suspend

進入待機模式

systemctl hibernate

進入休眠模式

systemctl hybird-sleep

進入混合休眠模式

,
Comments
Welcome to tft每日頭條 comments! Please keep conversations courteous and on-topic. To fosterproductive and respectful conversations, you may see comments from our Community Managers.
Sign up to post
Sort by
Show More Comments
Copyright 2023-2024 - www.tftnews.com All Rights Reserved