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 d...
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.
Do we have to bring this up again? It's just boring.
systemd is here and it isn't going anywhere soon. It's an improvement over SysV, but the core init system is arguably less well-designed than some of the other options that were on the table 10 years ago when its adoption started. The systemd userspace ecosystem has significantly stifled development of alternatives that provide equivalent functionality, which has led to less experimentation and innovation in those areas. In many cases those systemd add-on services provide less functionality than what they have replaced, but are adopted simply because they are part of the systemd ecosystem. The core unit file format is verbose and somewhat awkward, and the *ctl utilities are messy and sometimes unfriendly.
Like most Red Hat-originated software written in the last 15 years, it valiantly attempts to solve real problems with Linux, and mostly achieves that, but there are enough corner cases and short-sighted design decisions that it ends up being mediocre and somewhat annoying.
Personally I hope that someone comes along and takes the lessons learned and rewrites it, much like Pulseaudio has been replaced by Pipewire. Perhaps if someone decides it needs rewriting in Rust?
The core unit file format is verbose and somewhat awkward, and the *ctl utilities are messy and sometimes unfriendly.
While I agree with the rest I don't particularly believe in this. The unit format is well structured and solves many pitfalls of previous approaches, it also supports configuring a myriad of different things from mounts to sockets and the network in a nice way.
Thanks for summarizing my feelings on systemd in a less inflammatory way than if I had written it myself.
I've found that most distributions have implemented it properly and for the most part it works quite well and stays out of my way, it's only when for some reason you have to dive into the minutiae of a unit file and getting into all the dependencies and stuff that it gets annoying quickly.
One of the big complaints of systemd detractors I read is that it’s “monolithic” and “taking over everything” and this “shouldn’t all be part of init”
You might want to point out that all the features outside of systemd-as-init are optional and can be replaced or ignored if you don’t want them. They also don’t run as PID 1
You do have to use systemd-journald, but you can also just forward it to syslog if you want
Sure, but if you’re trying to convince the groups that hates systemd, a preamble of “these don’t run in PID 1 and are just extra features you might find useful” could help
systemd brings much functionality. It can't follow unix philosophy because unix is 50 years old. the whole community drama about this systemd VS sysV VS OpenRC VS whatever comes up, is funny. There are distros that are systemd-free if you wish so much to avoid it.
"Do one thing well" isn't a philosophy that ages out. Every time that is forgotten, you're creating more tech debt. The effort required to retire tech debt is the biggest reason Windows is the travesty it is. Aging monolithic kernel-like monsters like systemd will be are a problem to be avoided with foresight and that simple philosophy.
Ignore it, you get C:Windows\System32\ntoskrnl.exe
This was refuted long ago. Systemd isn’t a single binary file doing everything, it’s a project that has many different binaries doing many different things. The only difference is that they are developed under one project to ensure they integrate well with each other. What your doing is like complaining that glibc tries to do everything, I mean it does open, read, write, malloc, printf, getaddrinfo, dlopen, pthread_create, crypt, login, exit and more… Xorg would be another example of a project that does many things instead of one very well.
Finally a systemd praise post after so many hateful remarks. I knew systemd could do dns resolving but just learned it could handle the entire network stack and replace NetworkManager. I have a question: How can services such as Apache adapt to both NM and systemd at the same time? NM and systemd have different wait-online services.
You can also add systemd-analyze for boot time analysis to the list.
How can services such as Apache adapt to both NM and systemd at the same time? NM and systemd have different wait-online services
If you look at the systemd unit for Apache you'll just find After=network.target - it doesn't wait-online at all. Apache doesn't really care if you're using NM or systemd-networkd, it simply queries the system (like the ip command does) to know what's going on with the network. It was designed as recommended for moderns programs: it is aware that your network might change and listens for the appropriate signals and takes care of the binds dynamically.
I knew systemd could do dns resolving but just learned it could handle the entire network stack and replace NetworkManager.
It depends on your use case. I have three machines and use NetworkManager on one of them and systemd-networkd on the others. The latter is great for static configurations, but for a notebook that roams WiFi networks, it doesn't make the most sense.
imagine some kind of GUI like Windows has for system services
The problem is that systemd has so many possible options and ways to do things that you'll either end up with something that "lags behind the actual systemd resources" or a glorified text editor specially made to write systemd units.
People have been making services for decades and systemd is 13 years old. I kind of feel like it probably has virtually all of the options its ever going to have. Also most of what people would use such a GUI for is to start stop restart enable disable the thing people have been doing for an eternity which doesn't require even displaying the unit file.
Very interesting article with lots of links that I'm sure to revisit often.
I use Linux daily and was not aware of all the possibilities that systemd has to offer.
Some of the cruft I use nowadays to manage Linux machines can be optimized by simply moving over to the systemd equivalent. Of particular interest to me are: triggers, timers, file monitoring, and ntp.
I stopped using resolved as it tends to ignore what I tell it to do and still grab DNS from the router which I don't want and can't disable on the proprietary router.
openresolv/Resolveconf was never broken in the first place so I'm not sure what systemd was trying to fix with this.
Having choice is the best part of Linux, but Systemd is something so ubiquitous to Linux that it might as well be called Systemd/Linux instead of GNU/Linux.
When you think of it like that, it feels much less like a bloated behemoth that needs to be de-monopolised and more like an integral piece of the puzzle that is turning the Linux kernel into an functional operating system.
systems always implies Linux, but Linux doesn't necessarily imply systemd.
I always try to cover most of my stack with systemd components because they actually tend to be quite sane with a very transparent configuration. It's no surprise a lot of distributions picked it up. As you said, it does exactly that, make an OS based on Linux easily available. Sure you can do the same with a variety of other tools, but just letting systemd do the heavy lifting for you sure is tempting.
That doesn't mean it's the only choice. I'd love to try Chimera Linux one day which doesn't include systemd (in fact it doesn't include a lot of stuff most other distributions do) but it ticks a lot of boxes for many.
Very cool. I had no idea systemd sort of has a cron replacement. While in I don't think I'll switch from cron in the immediate future, it's really good to know.
Systemd timers are way, way better than cron. Because can audit them, view when they last run, next expected run, can be set to persist with reboot or not, aggregate logs under journalctl, can do amazing things such as "x minutes after boot", can be configured not to run again until the last run is complete etc... https://opensource.com/article/20/7/systemd-timers
You can do most of that with cron as well https://man.archlinux.org/man/fcrontab.5.en. If you want details about successful runs I think you would have to ensure you always logged.
It isn't always about being better. Docker has its use cases more for single binaries, LXD provides a nice interface while systemd-nspawn is built in and allows you to setup containers with a a common and known unit file. It also allows you to control the containers with the same systemd tools you use for your host machine, zero learning curve and you're less likely to have to enter containers.
Another example, I might not want to install LXD/LXC on a low resource system as it will bring snap and waste resources and systemd fixes that.
All of this shit packed in is why it sucks. Do one thing and do it well. Try setting up a script to run on boot that doesn't stop executing until you want to turn your pc off and watch all traces of sanity drain from your being. Now try it on freebsd. Much much easier
Did a couple of times, no issues. Simply add KillSignal=SIGINT or ExecStop=/bin/kill -s SIGINT -$MAINPID & /bin/kill -s SIGINT -$MAINPID and it will work out.
Systemd together with NetworkManager are two pieces of software I really dislike. They go against the very Unix philosophy. I like being able to piece all the bricks together on my own, not having monolithic pieces of software that try to do everything.
You make it sound as if it’s a religion … UNIX isn’t a dogma handed down by an infallible being, just a piece of software that made sense for its time. Todays needs are different than the needs 40 years ago, so ofc things have to change.
Red Hat didn't "close up the source" to anything. All the source to RHEL is available in CenOS Stream's git repos. All of the source to all Red Hat products is available in upstream projects too. Nothing's "closed".
What was announced was that the source to RHEL would only be publicly published in git (with history, tagged releases, etc.) instead of publically available SRPMs (unless you use a Red Hat account — even a free one — then you could also download SRPMs).
Where are those alternatives? I have not seen anything that is Baustoff convincing yet...
It is not a project owned by redhat... the lead guy not even works there anymore. So the more interesting question is: What happens if Microsoft closes down the project? The answer: It will be forked.
Ah yes, a piece of software that people can choose to use or not use is just like an unexpected, devastating disease that no one in their right mind would ever choose to have and that causes huge amounts of suffering and can be incredibly difficult or impossible to treat.
Yep, cancer patients and survivors totally think having cancer is just like using systemd. 🤦🏻♀️
How on earth can you say that? Systemd, while not perfect, creates a system that helps newbies come in and understand Linux, helps Linux grow. Afterwards they can shift to a non systemd distro, but systemd provides a valuable tool.
Hmm that's an interesting take on systemd. Not sure if anyone would be pivoting to a non-systemd distro after experiencing it... Well I've been using Linux before systemd and I wouldn't switch back to what we had before simply because it makes my life easier in so many ways.
But yes, I see how less fragmented and more approachable a systemd distro will look for a beginner.
creates a system that helps newbies come in and understand Linux, helps Linux grow.
Not sure about this.
A new user probably don't care (and rightly so) about how a certain service is started or stopped, it just need to work, which was true even before systemd.
Actually, its an opaque system that makes it much harder to understand what is going on because it's a declarative file that is consumed in a non-obvious way by code written in c which is not going to be remotely comprehensible to them. Most people are apt to google for the magic incantation that appears to match their problem without understanding anything.
Not only are simple and easy not the same they are opposing interests in most actual practices.
I had an extremely simple Funtoo (Gentoo derived) installation it had bios boot -> 4 line grub.cfg with explicitly specified kernel and initrd. Making a kernel involved cding to the directory where the new kernel was making it copying a file and changing a text file to point to the new kernel. Understanding how software was built was work because you actually have to specify things you want vs don't want but it was extremely simple. In fact everything was like that from boot, build, services. Anyone who took a few hours could probably trace it from the first line of grub.cfg to the last service starting up.
I have a more complicated void install that uses rEFInd -> zfsbootmenu . When a new kernel is installed dkms rebuilds modules and dracut handles preparing the boot up, updating automatically creates a snapshot and zfsbootmenu makes it possible to boot into a prior version of your OS. I set none of it up it was configured by an installer and when I messed something up it was a LOT more work to understand how it works and it was impossible to trace it from end to end without googling and reading documentation.
I have a single board computer running a derivative of Ubuntu. The official installation procedure that you are supposed to be able to do remotely doesn't work at all so I plugged a monitor and keyboard to it loaded the image to a sd card and booted and ran the commands it said to run and it works without issue. It's opaque but easy to use and if it ever doesn't I'll probably just reinstall the image from scratch and run the commands it said to run.
I would recommend Ubuntu/Mint if you just want to do things. If you actually want to understand it for its own sake I would recommend something simple instead of easy.
Same reason as for all those years these old people are holding a grudge for...
It is not Unix philosophy (nothing is these days), it does not solve any problem they ever had (it does), it is no improvement over what we had before (it is) and even makes some broken and moronic things harder (it does), it is insecure (it improves overall system security), and it is one monolithic blob (it is not). Before systemd nothing depended on the init system (true, but then it did nothing useful that made having such a dependency worthwhile), and before systemd we were all free to use other init systems and distributions did not pick one for their users (they always did, offering additional inits only as unsupported iption just likenthey do now).
That's the typical list you get.
Oh, and it was shoved down all our throats by the mighty Lennart himself, backed by several multi billion dollar companies that brided thousands of distribution developers to destroy Linux (it was not).
Funnily enough it is pretty much the same BS we had when that monster of complexity called sysv init was introduced into distributions, replacing a simple script with a forest of symlinks. Of course the community was much smaller then and so we had a loser number of idiots to shout at everybody else.