Yakkety Yak MATE rc.local 不存在

Yakkety Yak MATE rc.local 不存在

我是第一次在这里发帖,不熟悉协议。我在这里看到了一个参考16.10 rc.local 不存在 并尝试使用该命令

命令是

sudo systemctl enable rc-local.service

对我来说,16.10 MATE 中的该命令提供了以下内容(无法在此处弄清楚格式,遗憾):

$ sudo systemctl enable rc-local.service
[sudo] password for chris: 
The unit files have no installation config (WantedBy, RequiredBy, Also, Alias
settings in the [Install] section, and DefaultInstance for template units).
This means they are not meant to be enabled using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
   .wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
   a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
   D-Bus, udev, scripted systemctl call, ...).
4) In case of template units, the unit is meant to be enabled with some
   instance name specified.

重启无效。

答案1

一个解决方案

一个快速的解决方法(我不知道这是否是规范的方法):

在终端中执行:

sudo touch /etc/rc.local
sudo chmod +x /etc/rc.local
sudo printf '#!/bin/bash\nexit 0' > /etc/rc.local
sudo reboot

之后系统启动时会调用 rc.local。输入你想要的内容。

背景

如果你在终端中执行:

sudo systemctl edit --full rc-local

您可以看到头部注释包含如下行:

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.

这表明,在这个系统中,如果有一个/etc/rc.local可执行文件,那么它将被自动拉入 multi-user.target。因此,您只需创建相应的文件 ( sudo touch...) 并使其可执行 ( sudo chmod +x ...)。

相关内容