news 2026/5/28 16:13:27

How to Correctly Edit systemd’s .service File So That It Does Not Get Overwritten During the Future

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
How to Correctly Edit systemd’s .service File So That It Does Not Get Overwritten During the Future

Couple of years ago I ran into this issue where amavis service kept crashing on me and that has caused issues with my e-mail server. Solution was found so why am I writing about it? What seems to be the problem? Well… IF I only edited theamavis.servicefile, reloaded the daemon and restarted the service my solution would work. Temporarily. It would work until one of the futureamavisd-newpackage upgrades overwrites my change and then amavis would crash again and my e-mail server would be dead for few hours… Don’t ask me how I know… Traumatic events… Emotional damage… 😉 Anyroad… How to make this change permanent so that I don’t have to worry about it in the future? Usesystemctl editas root.

sudo systemctl editamavis

Replaceamaviswith the name of the service that You’re trying to modify.

You will be presented with something similar to this:


Make thenecessary changes in the correct place:


As You can see – there is a section at the top of the file that You need to place the changes in.

Placing changes in the wrong section of the file and saving them will result in error:

Editing “/etc/systemd/system/amavis.service.d/override.conf” canceled: temporary file is empty.


Service file contains sections. They are clearly marked with the square brackets [ and ]. My change falls into the [Service] section. As You can see I added that in my edit. IF You won’t add the correct section when creatingoverride.confyour changes will be ignored and when you’ll query the status of the service You will see something similar to this:

Jul 19 11:57:04 mail.andrzejl.eu systemd[1]: /etc/systemd/system/amavis.service.d/override.conf:1: Assignment outside of section. Ignoring.

So You have edited the file:


IF You made a mistake and You do NOT want to save the file press

+

and then press

.

To save the file press

+

and confirm with

and then

.


Now reload the daemon and restart your service

sudo systemctl daemon-reload
sudo systemctl restart amavis


You can now check the status and the modifications of the .service file. Run the following commands:

systemctl status --no-pager amavis
systemctl cat amavis


As You can see the service is active, running and no changes were ignored AND the override.conf is listed below the amavis.service file.

I hope this helps!

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/28 16:13:00

Arduino智能时钟与无接触夜灯DIY:从电路设计到混凝土外壳制作

1. 项目概述与设计思路几年前,我在工作室里捣鼓一些废弃的混凝土块和闲置的Arduino Nano时,萌生了一个想法:能不能把冰冷的工业材料与智能化的电子模块结合起来,做一件既有工业美学又具备实用功能的桌面摆件?于是&…

作者头像 李华
网站建设 2026/5/28 16:12:13

Arduino激光对战系统智能电池充电模块设计与实现

1. 项目概述与核心价值在任何一个需要移动或长时间运行的电子项目中,电池管理都是那个“沉默的守护者”。它不直接参与酷炫的功能实现,却决定了整个系统的稳定性和用户体验的底线。尤其是在像激光对战(Laser-tag)这类高互动性、多…

作者头像 李华