Systemd: Hidden Gems for a Better Linux
tadeubento.com
external-link
Systemd is incredibly versatile and most people, including myself, are unaware of its full potential. Despite its usefulness, it is often overlooked due to controversy and the current state of things when it comes to software development. Begin today your journey thought Systemd's capabilities and discover how to efficiently manage systems with fewer processes than traditionally used.

After a few conversations with people on Lemmy and other places it became clear to me that most aren’t aware of what it can do and how much more robust it is compared to the usual “jankiness” we’re used to.

In this article I highlight less known features and give out a few practice examples on how to leverage Systemd to remove tons of redundant packages and processes.

And yes, Systemd does containers. :)

Dandroid
link
fedilink
English
161Y

I never used Linux before systemd, so I never understood the drama. I use it a ton. Mostly to run my rootless containers via podman. I have a template service file for this, and I just change a few things, systemctl link, enable, and start. And voila. My container is running as a service that I can start and stop like any other service.

@d_k_bo@feddit.de
link
fedilink
English
51Y

Replaces crontab with something auditable that actually makes sense and is easy to use

Is there an easier/quicker way than having to create a service unit and a timer unit by hand?

Norgur
link
fedilink
11Y

But of I have to use separate tools… Can’t I just use a generator for a crontab? That’s not an advantage

@dot20@lemmy.world
link
fedilink
English
11Y

I believe if you create a crontab on a systemd system, it actually synthesizes systemd timers from the crontab entries

@maor@lemmy.org.il
link
fedilink
English
201Y

Love me some systemd timers. Much more fun than cron.

  • Sane handling of environment variables with EnvironmentFile=
  • Out of the box logging. Especially useful is the ability to journalctl -f to watch long-running processes, which I’m not sure whether possible with cron
  • The ability to trigger the service manually rather than setting the timer to * * * * *, then forgetting it’s supposed to run in a minute, get distracted, come back in 15 minutes

My only complaint is it’s a bit verbose. I’d rather have it as an option inside the .service file. The .timer requires some boilerplate like [Unit].description (it… uh… triggers a service. that’s the description), and WantedBy=timers.target. But these are small prices to pay

@TCB13@lemmy.world
creator
link
fedilink
English
121Y

Another thing I particularly like is systemctl list-timers --all and its overview of the timer statuses and when they’re going to run next.

Atemu
link
fedilink
English
21Y

My only complaint is it’s a bit verbose. I’d rather have it as an option inside the .service file. The .timer requires some boilerplate like [Unit].description (it… uh… triggers a service. that’s the description), and WantedBy=timers.target.

This can be solved through abstraction and automation.

In NixOS for example, you can declare a service that runs an arbitrary script every day like this:

{
  systemd.services.your-service-here = {
    script = "echo 'Hello, world!'";
    startAt = "daily";
  };
}

This automatically creates a service file with the script in its ExecStart and an accompanying timer which runs daily and is part of the timers.target.

@maor@lemmy.org.il
link
fedilink
English
21Y

Yep, I manage my servers and local machine with Ansible so I abstracted it with a role. This is indeed not that bad of a con because it’s still plaintext so automation is easy, but it’s still a minor issue ;)

@Janis@feddit.de
link
fedilink
English
-161Y

i hate systemd and will do anything to not use it. the fanboys wont ack the many downsides (https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1988119 or https://news.ycombinator.com/item?id=25862927) or that it breaks the idea of how software should work. Lennart the jerk who sold his soul to red hat is just the tip of the iceberg. red hat streams start closing and now you who uses systemd will start losing. just wait for it …or keep telling yourself you are on lemmy but not on reddit because of the broke system?

@constantokra@lemmy.one
link
fedilink
English
01Y

I like systemd, but i’m glad you hate it so strongly. I feel much the same about snaps. Strong feelings one way or another make sure there are always alternatives, and that’s great.

@TCB13@lemmy.world
creator
link
fedilink
English
2
edit-2
1Y

Hmm… software has bugs. Still interesting how it mostly affected only people running on Azure. lol

What really breaks the “idea of how software should work” is Docker and all its bloat, dockerfiles, Docker Hub and the fact that newer developers aren’t able to ship anything without those overly bloated environments.

@Janis@feddit.de
link
fedilink
English
-51Y

is docker more bloated than gtk? but yes, docker is sad too. :-(

Guys, downvotes are not the DISLIKE button, let’s not become reddit please

@mea_rah@lemmy.world
link
fedilink
English
121Y

That comment is just spreading FUD. One of the links is just link to someone’s message saying they hate systemd. The other is just link to random (resolved) bug.

People aren’t disliking the comment, it’s actually terrible comment with no value.

Admin dont like changes in their workflow and Systemd changes a lot of things, for better or for worse. That being said i do like how Systemd does things and wish for an overall better experience for linux not a worse one.

@TCB13@lemmy.world
creator
link
fedilink
English
61Y

Yes, like nftables recently did change a LOT of things.

nftables? Is this a replacement for ipchains or something? :-|

@TCB13@lemmy.world
creator
link
fedilink
English
11Y

Ahaha you wish. nftables replaces iptables and it has already happened in Debian 11.

nftables adds a new tool, called nft, which replaces all other tools from iptables, arptables and ebtables. From an architectural point of view it also replaces those parts of the kernel that deal with run-time evaluation of the packet filtering rule set.

Read the complete explanation of the why is is happening here: https://developers.redhat.com/blog/2016/10/28/what-comes-after-iptables-its-successor-of-course-nftables

Create a post

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don’t control.

Rules:

  1. Be civil: we’re here to support and learn from one another. Insults won’t be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it’s not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don’t duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

  • 1 user online
  • 127 users / day
  • 422 users / week
  • 1.16K users / month
  • 3.85K users / 6 months
  • 1 subscriber
  • 3.68K Posts
  • 74.2K Comments
  • Modlog