Debian 9-12 重新启用 /etc/rc.local

自从 Debian 9 开始,Debian 默认不带 /etc/rc.local 文件,而 rc.local 服务却还是自带的,所以我们只要重新将服务启动即可。

创建缺失的 /etc/rc.local

cat <<EOF >/etc/rc.local
#!/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.

exit 0
EOF

chmod +x /etc/rc.local

启用并立即启动服务

systemctl enable --now rc-local

执行后,可能回显 The unit files have no installation config 类似的警告,无视即可。命令意义如下:

  • systemctl 是 Systemd 的主命令,用于管理系统和服务
  • enable 是一个选项,用于设置服务在系统启动时自动运行
  • --now 是一个选项,用于立即启动服务,而不是等到下次系统启动
  • rc-local 是一个服务,通常用于在系统启动时运行一些自定义的脚本或命令
文章作者: 若海; 原文链接: https://www.rehiy.com/post/563/; 转载需声明来自技术写真 - 若海

添加新评论