ArchLinux / Manjaro 開啟 rclocal.local 服務(wù) 一鍵腳本

  • 創(chuàng)建一個(gè)文件 setup.sh
  • 將下面的內(nèi)容復(fù)制進(jìn) setup.sh
#!/bin/bash

echo 創(chuàng)建服務(wù)文件
sudo touch /usr/lib/systemd/system/rc-local.service
sudo echo '''[Unit]
Description="/etc/rc.local Compatibility" 

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardInput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target''' >  /usr/lib/systemd/system/rc-local.service

echo 啟用服務(wù)
sudo systemctl enable rc-local.service

echo 創(chuàng)建rc.local文件
sudo touch  /etc/rc.local
echo '''#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# -----------替換橫杠間的內(nèi)容為需要開機(jī)執(zhí)行的命令---------------
echo rc.local 文件正常!
# -----------替換橫杠間的內(nèi)容為需要開機(jī)執(zhí)行的命令---------------
exit 0''' > /etc/rc.local

echo 授權(quán)
sudo chmod +x /etc/rc.local

echo 測試
sudo sh /etc/rc.local
  • 在setup.sh的路徑下打開終端
  • 在終端中執(zhí)行 chmod +x setup.sh
  • 然后 再運(yùn)行腳本 ./setup.sh

Reference:Archlinux systemd 開機(jī)執(zhí)行rc.local

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容