X-osadmin的自留地 X-osadmin的自留地
  • ? 博客主页•Index
  • ? 技术小絮·Tech
  • ✍ 点点滴滴·Diary
  • ? 作品发布·Works ↓
    • 下载中心
    • Y-OS
    • SpeedTest · 云测速
  • ? 专题文章·Catalogs
  • ? 友情链接
  • ? 博客主页•Index
  • ? 技术小絮·Tech
  • ✍ 点点滴滴·Diary
  • ? 作品发布·Works ↓
    • 下载中心
    • Y-OS
    • SpeedTest · 云测速
  • ? 专题文章·Catalogs
  • ? 友情链接
首页 技术小絮 Debian 11启用rc.local方法

Debian 11启用rc.local方法

xosadmin 6月前

rc.local是一个令大家耳熟详的文件,它在Redhat系列操作系统中可以让用户添加自定义开机脚本并运行。但是在Debian 11操作系统中,这个功能不被默认开启。这篇文章将介绍如何开启rc.local。话不多说,开始~

  1. 先通过以下命令对systemd注入rc-local服务:

cat>>/etc/systemd/system/rc-local.service<<EOF
[Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local

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

[Install]
WantedBy=multi-user.target
EOF

2. 执行daemon reload和启动服务开机启动

systemctl daemon-reload && systemctl enable rc-local

3. 创建一个空白的rc.local文件,并写入头尾,如下方

touch /etc/rc.local

cat /etc/rc.local

#!/bin/sh -e

<your command>

exit 0

4. 对rc.local赋予权限以执行

chmod a+x /etc/rc.local

到这里,就全部完成了,在下一次重启中,该文件将会被自动调用并执行。

Enjoy~

0
猜你喜欢
  • Bark提示TokenExpired的解决方法
  • Debian 11通过apt安装proxmox 7
  • 为proxmox 6/7一键开启bbr
  • CentOS迁移后开机提示lvm not found的解决方法
  • curl: (35) Peer reports incompatible or unsupported protocol version的解决方法
  • 超微(SuperMicro) IPMI的java IKVM提示”javax.net.ssl.SSLHandshakeException”的解决方法
评论 (0)
再想想
    暂无评论
xosadmin
站长
Codes learner / Love Linux & OpenWrt
110
文章
2
评论
0
获赞

文章聚合

  • ♥ X-osadmin’s Website ♥
  • 下载中心
  • 网站通知
  • Y-OS
  • 友情链接
  • 联系站长
  • X-osadmin’s Git Server
Copyright © 2016-2022 X-osadmin的自留地. Designed by nicetheme.