久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

linux如何強(qiáng)制關(guān)機(jī)

共計(jì) 2405 個(gè)字符,預(yù)計(jì)需要花費(fèi) 7 分鐘才能閱讀完成。

自動(dòng)寫(xiě)代碼機(jī)器人,免費(fèi)開(kāi)通

這篇文章將為大家詳細(xì)講解有關(guān) linux 如何強(qiáng)制關(guān)機(jī),丸趣 TV 小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

概念和術(shù)語(yǔ)

內(nèi)核模塊允許 Linux 內(nèi)核在運(yùn)行時(shí)動(dòng)態(tài)地向其中插入和刪除代碼。這些模塊是具有獨(dú)立功能的程序,可以被單獨(dú)編譯,但無(wú)法獨(dú)立運(yùn)行。模塊在運(yùn)行時(shí)作為內(nèi)核的一部分在內(nèi)核空間內(nèi)運(yùn)行。

操作實(shí)戰(zhàn)   場(chǎng)景一:使用 Kgotobed 強(qiáng)制關(guān)機(jī)難度★★★演示發(fā)行版 archlinux 涉及命令 gotobed 安裝

在 archlinux 上要安裝  kgotobed,首先需要安裝  dkms  和  linux-headers  這兩個(gè)包:

sudo pacman -S dkms linux-headers --noconfirm

然后去 github 上克隆它的源代碼:

git clone https://github.com/nikital/kgotobed.git

最后我們對(duì)源代碼進(jìn)行手工編譯:

cd kgotobed/sudo make install

make install  命令會(huì)完成以下三件事情:

鴻蒙官方戰(zhàn)略合作共建——HarmonyOS 技術(shù)社區(qū)

通過(guò) DKMS 注冊(cè)  kgotobed.ko

安裝  gotobed  命令到  /usr/local/bin  下

在 systemd 中注冊(cè)、啟用并運(yùn)行  kgotobed.service

使用

直接運(yùn)行  gotobed  就能看到設(shè)置的強(qiáng)行關(guān)機(jī)的時(shí)間:

[vagrant@archlinux kgotobed]$ gotobed 22:00Current bedtime is 2018-04-13 01:00:00Setting bedtime to 2018-04-12 22:00:00Bedtime will be in 10 hours 32 minutes

不過(guò)你不能把時(shí)間調(diào)到更晚 hellip; hellip;

[vagrant@archlinux kgotobed]$ gotobed 2:00Current bedtime is 2018-04-13 01:00:00Error: Attempting to postpone bed time, it doesn t work like this...

要想調(diào)整默認(rèn)時(shí)間,你需要修改  /etc/systemd/system/kgotobed.service。

原始的  kgotobed.service  內(nèi)容如下所示:

[Unit]Description=kgotobed: Poweroff at bedtimeAfter=dkms.service [Service]Type=oneshotExecStartPre=/sbin/modprobe kgotobedEnvironment=TIME=01:00ExecStart=/usr/local/bin/gotobed -f ${TIME} [Install]WantedBy=multi-user.target

我們將其中的  TIME=01:00  改成  TIME=02:00  后重啟系統(tǒng),再次執(zhí)行  gotobed  可以看到時(shí)間已經(jīng)修改了:

[vagrant@archlinux ~]$ gotobed Current bedtime is 2018-04-13 02:00:00

刪除 kgotobed

要逃脫強(qiáng)制關(guān)機(jī)的命運(yùn),幾乎唯一的辦法就是卸載 kgotobed 了。

我們可以在源代碼目錄中執(zhí)行  make uninstall  進(jìn)行卸載:

[vagrant@archlinux ~]$ cd kgotobed/[vagrant@archlinux kgotobed]$ sudo make uninstalldkms remove kgotobed/1.0 --all -------- Uninstall Beginning --------Module: kgotobedVersion: 1.0Kernel: 4.15.15-1-ARCH (x86_64)------------------------------------- Status: Before uninstall, this module version was ACTIVE on this kernel. kgotobed.ko: - Uninstallation - Deleting from: /usr/lib/modules/4.15.15-1-ARCH/extra// - Original module - No original module was found for this module on this kernel. - Use the dkms install command to reinstall any previous module version. depmod........... DKMS: uninstall completed. ------------------------------Deleting module version: 1.0completely from the DKMS tree.------------------------------Done.rm -f /usr/local/bin/gotobedrm -f /etc/systemd/system/kgotobed.servicesystemctl daemon-reload[vagrant@archlinux kgotobed]$

關(guān)于“l(fā)inux 如何強(qiáng)制關(guān)機(jī)”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。

向 AI 問(wèn)一下細(xì)節(jié)

丸趣 TV 網(wǎng) – 提供最優(yōu)質(zhì)的資源集合!

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-12-07發(fā)表,共計(jì)2405字。
轉(zhuǎn)載說(shuō)明:除特殊說(shuō)明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請(qǐng)注明出處。
評(píng)論(沒(méi)有評(píng)論)
主站蜘蛛池模板: 临武县| 稷山县| 比如县| 无棣县| 类乌齐县| 大庆市| 珲春市| 新田县| 陕西省| 白银市| 金秀| 玉屏| 延寿县| 准格尔旗| 高安市| 老河口市| 灯塔市| 漳浦县| 新余市| 漯河市| 和平区| 广宗县| 喀什市| 双鸭山市| 屯昌县| 吴忠市| 金川县| 五指山市| 新蔡县| 汾阳市| 安平县| 泉州市| 乐安县| 明光市| 柳河县| 沂南县| 顺平县| 桃园市| 乐昌市| 株洲市| 稷山县|