日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

【Linux】一步一步学Linux——systemctl命令(147)

發(fā)布時間:2024/4/21 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Linux】一步一步学Linux——systemctl命令(147) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

00. 目錄

文章目錄

    • 00. 目錄
    • 01. 命令概述
    • 02. 命令格式
    • 03. 常用選項(xiàng)
    • 04. 參考示例
    • 05. 附錄

01. 命令概述

systemctl命令是系統(tǒng)服務(wù)管理器指令,它實(shí)際上將 service和chkconfig這兩個命令組合到一起。

Centos7之后從init完全換成了systemd的啟動方式,systemd 啟動服務(wù)的機(jī)制主要是通過 systemctl 的這個系統(tǒng)服務(wù)管理指令來處理。systemctl在用法上也囊括 service / chkconfig / setup / init 的大部分功能。

任務(wù)舊指令新指令
使某服務(wù)自動啟動chkconfig --level 3 httpd onsystemctl enable httpd.service
使某服務(wù)不自動啟動chkconfig --level 3 httpd offsystemctl disable httpd.service
檢查服務(wù)狀態(tài)service httpd statussystemctl status httpd.service (服務(wù)詳細(xì)信息) systemctl is-enabled httpd.service (僅顯示是否 Active)
顯示所有已啟動的服務(wù)chkconfig --listsystemctl list-units --type=service
啟動某服務(wù)service httpd startsystemctl start httpd.service
停止某服務(wù)service httpd stopsystemctl stop httpd.service
重啟某服務(wù)service httpd restartsystemctl restart httpd.service
某服務(wù)重新加載配置文件service httpd reloadsystemctl reload httpd.service

02. 命令格式

格式:systemctl [選項(xiàng)...] {命令} ...

03. 常用選項(xiàng)

-start 啟動服務(wù) -stop 停止服務(wù) -restart 重啟服務(wù) -enable 使某服務(wù)開機(jī)自啟 -disable 關(guān)閉某服務(wù)開機(jī)自啟 -status 查看服務(wù)狀態(tài) -list-units –type=service 列舉所有已啟動服務(wù)

04. 參考示例

4.1 輸出所有已經(jīng)啟動服務(wù)

[deng@localhost ~]$ systemctl

4.2 輸出所有已經(jīng)啟動的單元

[deng@localhost ~]$ systemctl list-units

4.3 顯示啟動失敗的服務(wù)

[deng@localhost ~]$ systemctl --failedUNIT LOAD ACTIVE SUB DESCRIPTION ● network.service loaded failed failed LSB: Bring up/down networking ● postfix.service loaded failed failed Postfix Mail Transport Agent

4.4 查看所有已經(jīng)安裝的服務(wù)

[deng@localhost ~]$ systemctl list-unit-files UNIT FILE STATE proc-sys-fs-binfmt_misc.automount static dev-hugepages.mount static dev-mqueue.mount static proc-fs-nfsd.mount static proc-sys-fs-binfmt_misc.mount static sys-fs-fuse-connections.mount static

4.5 啟動服務(wù)

[root@localhost ~]# systemctl start sshd

4.6 停止服務(wù)

[root@localhost ~]# systemctl stop sshd

4.7 重啟服務(wù)

[root@localhost ~]# systemctl restart sshd

4.8 重新加載服務(wù)配置

[root@localhost ~]# systemctl reload sshd

4.9 查看服務(wù)狀態(tài)

[root@localhost ~]# systemctl status sshd ● sshd.service - OpenSSH server daemonLoaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)Active: active (running) since 六 2019-08-17 20:56:41 CST; 1min 10s ago

4.10 查看服務(wù)是否開機(jī)啟動

[root@localhost ~]# systemctl is-enabled sshd enabled [root@localhost ~]#

4.11 開機(jī)自動啟動服務(wù)

[root@localhost ~]# systemctl enable sshd [root@localhost ~]#

4.12 開機(jī)不啟動服務(wù)

[root@localhost ~]# systemctl disable sshd Removed symlink /etc/systemd/system/multi-user.target.wants/sshd.service. [root@localhost ~]#

4.13 顯示服務(wù)幫助信息

[root@localhost ~]# systemctl help sshd

4.14 重新加載systemd

[root@localhost ~]# systemctl daemon-reload

4.15 重新啟動系統(tǒng)

[root@localhost ~]# systemctl reboot

4.16 關(guān)機(jī)

[root@localhost ~]# systemctl poweroff

4.17 休眠

[root@localhost ~]# systemctl hibernate

hibernate:休眠模式則是將系統(tǒng)狀態(tài)保存到硬盤當(dāng)中,保存完畢后,將計算機(jī)關(guān)機(jī)。當(dāng)用戶嘗試喚醒系統(tǒng)時,系統(tǒng)會開始正常運(yùn)行,然后將保存在硬盤中的系統(tǒng)狀態(tài)恢復(fù)回來。因?yàn)閿?shù)據(jù)需要從硬盤讀取,因此喚醒的速度比較慢(如果你使用的是 SSD 磁盤,喚醒的速度也是非常快的)。

4.18 待機(jī)

[root@localhost ~]# systemctl suspend

suspend:暫停模式會將系統(tǒng)的狀態(tài)保存到內(nèi)存中,然后關(guān)閉掉大部分的系統(tǒng)硬件,當(dāng)然,并沒有實(shí)際關(guān)機(jī)。當(dāng)用戶按下喚醒機(jī)器的按鈕,系統(tǒng)數(shù)據(jù)會從內(nèi)存中回復(fù),然后重新驅(qū)動被大部分關(guān)閉的硬件,所以喚醒系統(tǒng)的速度比較快。

4.19 混合休眠模式(同時休眠到硬盤并待機(jī))

[root@localhost ~]# systemctl hybrid-sleep

4.20 相當(dāng)于telinit 3 或 telinit 5

[root@localhost ~]# systemctl isolate graphical.target

graphical.target:就是文字界面再加上圖形界面,這個 target 已經(jīng)包含了下面的 multi-user.target。

multi-user.target:純文本模式!

rescue.target:在無法使用 root 登陸的情況下,systemd 在開機(jī)時會多加一個額外的臨時系統(tǒng),與你原本的系統(tǒng)無關(guān)。這時你可以取得 root 的權(quán)限來維護(hù)你的系統(tǒng)。

emergency.target:緊急處理系統(tǒng)的錯誤,在無法使用 rescue.target 時,可以嘗試使用這種模式!

shutdown.target:就是執(zhí)行關(guān)機(jī)。

getty.target:可以設(shè)置 tty 的配置。

正常的模式是 multi-user.target 和 graphical.target 兩個,救援方面的模式主要是 rescue.target 以及更嚴(yán)重的 emergency.target。如果要修改可提供登陸的 tty 數(shù)量,則修改 getty.target。

4.21 列出所有已經(jīng)啟動的服務(wù)

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

4.22 查看目前是否運(yùn)行指定服務(wù)

[root@localhost ~]# systemctl is-active sshd active [root@localhost ~]#

4.23 列出unit的配置

[root@localhost ~]# systemctl show

4.24 查看服務(wù)的配置

[root@localhost ~]# systemctl show sshd.service

4.25 注銷服務(wù)

[root@localhost ~]# systemctl mask sshd.service Created symlink from /etc/systemd/system/sshd.service to /dev/null. [root@localhost ~]#

4.26 反注銷服務(wù)

[root@localhost ~]# systemctl unmask sshd.service Removed symlink /etc/systemd/system/sshd.service. [root@localhost ~]#

4.27 只查看服務(wù)類型的unit

[root@localhost ~]# systemctl list-units --type=service --allUNIT LOAD ACTIVE SUB DESCRIPTIONabrt-ccpp.service loaded active exited Install ABRT coredump hooabrt-oops.service loaded active running ABRT kernel log watcherabrt-vmcore.service loaded inactive dead Harvest vmcores for ABRTabrt-xorg.service loaded active running ABRT Xorg log watcherabrtd.service loaded active running ABRT Automated Bug Reportaccounts-daemon.service loaded active running Accounts Servicealsa-restore.service loaded inactive dead Save/Restore Sound Card Salsa-state.service loaded active running Manage Sound Card State ( ● apparmor.service not-found inactive dead apparmor.service

4.28 進(jìn)入救援模式

[root@localhost ~]# systemctl rescue

4.29 進(jìn)入緊急救援模式

[root@localhost ~]# systemctl emergency

4.30 本機(jī) socket 的服務(wù)

[root@localhost ~]# systemctl list-sockets

05. 附錄

參考:【Linux】一步一步學(xué)Linux系列教程匯總

參考:https://blog.csdn.net/skh2015java/article/details/94012643

總結(jié)

以上是生活随笔為你收集整理的【Linux】一步一步学Linux——systemctl命令(147)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。