systemd edit后如何消除Warning

症状

> sudo systemctl start mihayo.service
Warning: The unit file, source configuration file or drop-ins of mihayo.service changed on disk. Run 'systemctl daemon-reload' to reload units.

然而,如果你老老实实去sudo systemctl daemon-reload后,你会发现,你的配置文件被覆写了。

1.强制覆盖

> locate mihayo.service
/etc/systemd/system/mihayo.service
/etc/systemd/system/multi-user.target.wants/mihayo.service

修改.service后:

sudo systemctl revert mihayo.service &&\
sudo systemctl daemon-reload &&\
sudo systemctl restart mihayo.service

2. override.conf

systemd限制: https://bbs.archlinux.org/viewtopic.php?pid=1379005#p1379005
要先空白赋值一次,才能覆盖Exec...参数:

### Editing /etc/systemd/system/mihomo.service.d/override.conf
### Anything between here and the comment below will become the contents of the drop-in file

[Service]
ExecStart=
ExecStart=/usr/bin/in.tftpd -s /home/frank/tftp/

### Edits below this comment will be discarded


### /etc/systemd/system/mihomo.service
# [Unit]
# #...
# [Service]
# ExecStart=/usr/bin/in.tftpd

修改默认systemd edit编辑器

vim ~/.bashrc # 添加`export EDITOR=vim`一行
sudo visudo # 取消注释`Defaults...EDITOR`一行

然后重启terminal。

posted @ 2024-12-31 09:30  Nolca  阅读(5)  评论(0编辑  收藏  举报