Paper plane - 2024年7月13日
type: channel
link: https://blog.ttoof.xyz/index.php/2024/07/13/
description: Your description here.
items: Debian/Ubuntu启用/etc/rc.local增加开机启动

Debian/Ubuntu启用/etc/rc.local增加开机启动
type: item
date: 2024-07-13T00:06:00+08:00
description: Debian/Ubuntu启用/etc/rc.local增加开机启动1、创建服务文件/etc/systemd/system/rc-local.servicenano /etc/systemd/system/rc-local.service[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 2、创建脚本文件/etc/rc.local（并给予执行权限）： 在exit 0前1行添加需要启动命令。 示例：给某些机型不会自启网卡添加开机自启网卡命令；nano /etc/rc.local#!/bin/sh -e ifup eno1 ifup eno1:1 exit 0 EOF /etc/rc.local文件添加执行权限chmod +x /etc/rc.local 3、设置rc-local开机启动，并启动服务systemctl enable rc-local.service systemctl start rc-local 查看启动状态是Active:active，则成功systemctl status rc-local