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. :)

  • marmarama@lemmy.world
    link
    fedilink
    arrow-up
    41
    arrow-down
    5
    ·
    2 years ago

    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?

    • TCB13@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      13
      arrow-down
      2
      ·
      2 years ago

      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.

      • astraeus@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        2 years ago

        I find systemctl to do a much better job than any alternative that comes stock with distros. I’m looking at you service

    • SpaceCadet@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      7
      arrow-down
      1
      ·
      2 years ago

      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.

      • w2qw@aussie.zone
        link
        fedilink
        arrow-up
        4
        ·
        edit-2
        2 years ago

        The dependency system takes a bit to understand but compared to like upstart it was a massive improvement.

          • Ghoelian@feddit.nl
            link
            fedilink
            English
            arrow-up
            5
            arrow-down
            1
            ·
            edit-2
            2 years ago

            Or, even worse, A start job is running for ... (10s / no limit)

          • dmar@lemmy.world
            link
            fedilink
            arrow-up
            1
            arrow-down
            1
            ·
            2 years ago

            I don’t see how exactly that is systemd’s fault.

            You are blaming it for having proper dependency handling?

            • SpaceCadet@sopuli.xyz
              link
              fedilink
              English
              arrow-up
              2
              arrow-down
              1
              ·
              2 years ago

              I’m blaming it for making it a pain in the ass to debug dependency problems and for having the confusing, non-intuitive, overly verbose and redundant syntax that probably caused the problem in the first place.

              Like, who the hell can memorize all the subtle differences in behavior between After=, Requires=, Wants=, Requisite=, BindsTo=, PartOf=, UpHolds= and then all their “reverse” equivalents?

  • ozymandias117@lemmy.world
    link
    fedilink
    English
    arrow-up
    35
    arrow-down
    2
    ·
    2 years ago

    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

    • TCB13@lemmy.worldOP
      link
      fedilink
      arrow-up
      7
      ·
      2 years ago

      all the features outside of systemd-as-init are optional and can be replaced or ignored if you don’t want them

      Yes, but the point of the article was kind of the opposite - simply try all the systemd tools and components and see how much better things can get.

  • jimakososx@lemmy.ml
    link
    fedilink
    arrow-up
    25
    arrow-down
    2
    ·
    2 years ago

    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.

      • rocketeer8015@discuss.tchncs.de
        link
        fedilink
        arrow-up
        1
        arrow-down
        1
        ·
        2 years ago

        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.

        • michaelrose@lemmy.ml
          link
          fedilink
          English
          arrow-up
          2
          ·
          2 years ago

          Splitting something into multiple executables doesn’t make something not monolithic just like splitting a program into multiple source files doesn’t make it not a monolith. It’s not a monolith when the different component parts can be cleanly factored out, replaced, and used outside of the original context or with different versions of related components This is in fact very hard. Much harder than making a monolith.

          For instance the X11 ecosystem isn’t a good example of a monolith because its designed to make it trivial to swap in different loosely coupled components. You don’t worry about needing your window manager and X11 to come from the same commit so they actually work. You can argue that the toolbox that systemd provides it is worth it but arguing that it’s not a monolith just screams I’m not a developer.

  • Quazatron@lemmy.world
    link
    fedilink
    arrow-up
    16
    ·
    2 years ago

    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.

    • TCB13@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      5
      arrow-down
      1
      ·
      2 years ago

      Thank you. NTP and DNS are the easiest to get into. Simply enable the services and move on.

      • t0m5k1@lemmy.world
        link
        fedilink
        arrow-up
        5
        arrow-down
        2
        ·
        2 years ago

        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.

        • TCB13@lemmy.worldOP
          link
          fedilink
          English
          arrow-up
          5
          arrow-down
          4
          ·
          edit-2
          2 years ago

          That’s most likely because… you didn’t read the manual! :D

          FallbackDNS= A space-separated list of IPv4 and IPv6 addresses to use as the fallback DNS servers. Please see DNS= for acceptable format of addresses. Any per-link DNS servers obtained from systemd-networkd.service(8) take precedence over this setting, as do any servers set via DNS= above or /etc/resolv.conf.

          Assuming your network is DHCP, edit your config eg. /etc/systemd/network/10-eth0.network:

          [DHCPv4]
          UseNTP=no
          UseDNS=no
          UseHostname=no
          

          Your system will not pick NTP and DNS servers and also ignore the hostname provided by the router. Also make sure you ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

          https://www.freedesktop.org/software/systemd/man/systemd.network.html#[DHCPv4] Section Options

          • t0m5k1@lemmy.world
            link
            fedilink
            arrow-up
            7
            arrow-down
            8
            ·
            2 years ago

            Oh yes 😆 hur der I didn’t read da manual. Why is it in a tread about systemd people lower themselves to this kind of response!

            And no I had read the manual and it’s down to how systemd handles IPv6 and rather than disable that I chose to disable resolved and return back to openresolv. Which works and is perfectly fine.

  • Skull giver@popplesburger.hilciferous.nl
    cake
    link
    fedilink
    arrow-up
    5
    ·
    2 years ago

    systemd has made my life so much easier in so many ways. Other people prefer messing with bash files and there are definitely better alternatives for services like systemd-resolved, but basic service and timer management has improved massively.

    I wish there was a good GUI for systemd, though. A lot of configuration options have moved to systemd files now, and for novices it’s hard to find what file does what and how to configure them. Several Linux distros and desktop environments have their own tools that read from/write to systemd files, but they’ll always lag behind the actual systemd resources.

    I think an official systemd GUI to manage services and networks would make Linux a lot more usable for people with some computer knowledge but no time or interest in reading man pages. I’d imagine some kind of GUI like Windows has for system services (titled “advanced system settings” or whatever) that can do things like manage network adapters, alter DNS config, start/stop/enable/disable services, the whole deal.

    • michaelrose@lemmy.ml
      link
      fedilink
      English
      arrow-up
      1
      ·
      2 years ago

      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.

  • gkpy@feddit.de
    link
    fedilink
    arrow-up
    1
    ·
    2 years ago

    systemd is great, but being disingenious isn’t helping anyone:

    chrony -> sd-timesyncd […] one less daemon

    just because it ships with systemd doesn’t mean it magically runs without it’s own process

  • Drito@sh.itjust.works
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    edit-2
    2 years ago

    And yes, Systemd does containers. :)

    Are systemd duplicates such as containers and systemd-boot are better than the existing ?

    • TCB13@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      6
      arrow-down
      1
      ·
      edit-2
      2 years ago

      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.

  • Rune@lemmy.ml
    link
    fedilink
    arrow-up
    0
    arrow-down
    1
    ·
    2 years ago

    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.

  • t0m5k1@lemmy.world
    link
    fedilink
    arrow-up
    10
    arrow-down
    17
    ·
    2 years ago

    Just no, there are already alternatives popping up in place of parts of systemd.

    And what happenes when redhat close this source up too?

    • Tobias Hunger@programming.dev
      link
      fedilink
      arrow-up
      9
      arrow-down
      1
      ·
      2 years ago

      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.

    • garrett@kbin.social
      link
      fedilink
      arrow-up
      8
      ·
      2 years ago

      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).

    • Thorned_Rose@kbin.social
      link
      fedilink
      arrow-up
      19
      arrow-down
      5
      ·
      2 years ago

      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 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 survives totally think having cancer is just like using systemd. 🤦🏻‍♀️

      • hansmeiser666@lemmy.world
        link
        fedilink
        arrow-up
        6
        arrow-down
        28
        ·
        edit-2
        2 years ago

        Except you’re NOT free to choose, every major distro shoves it into your face

        And it BEHAVES like cancer, that’s what I meant

        • be_excellent_to_each_other@kbin.social
          link
          fedilink
          arrow-up
          22
          arrow-down
          2
          ·
          edit-2
          2 years ago

          Except you’re NOT free to choose, every major distro shoves it into your face

          You can’t have been using Linux long if you think this is what not being free to choose means.

          Don’t use a “major distro”, use one made by likeminded folks. Example: https://www.devuan.org/

          Why do major distros have to make only the decisions you want them to make? Bugs the shit out of me that Gnome is the default desktop damn near everywhere, but so what? Are you paying their bills or otherwise contributing to some degree that they should change their decisions to suit you?

          Here’s a list from 2021: https://www.howtogeek.com/713847/the-best-linux-distributions-without-systemd/

          Another from2022: https://itsfoss.com/systemd-free-distros/

          Or build LFS without systemd.

          Or build Arch yourself without systemd.

          Want to remove it from Ubuntu? Here you go. I’m sure there are similar howtos for most major distros.

          The freedom of Linux and FLOSS is that you can roll up your sleeves and do it differently if you want to. Not that anyone owes it to you to do it for you. For that you have to hope other folks who have rolled up their sleeves have the same opinions you do - and in this case, some do!

          I have no concern about your opinion on systemd. But you seem really confused about what freedom is.

        • Tobias Hunger@programming.dev
          link
          fedilink
          arrow-up
          12
          arrow-down
          2
          ·
          2 years ago

          How is that different to when every distribution shoved their implementation of sysv-init into your face? You were never free to choose your init, it always came from the distribution. You could (and still can) replace the init system, if you are willing to do the work involved.

          That’s the whole point: Nobody is willing to do the work for one distribution, if they can just improve systemd and fix a whole bunch of distributions at once. That’s why developers flock to the systemd umbrella project to implement their ideas there, which is why systemd keeps getting cool be features for the plumbing layer of Linux – which is far more than just the init system.

        • GlowHuddy@lemmy.world
          link
          fedilink
          arrow-up
          6
          arrow-down
          2
          ·
          2 years ago

          Thinking about it from your point of view, maybe MS was right and Linux is a cancer too. Technically it behaves similarly to systemd, since most Unixes are actually Linuxes nowadays (excluding BSD ofc, but they are still in the minority, similarly to alternatives to systemd). It even is a binary blob as well!

          Should every distro use/develop a different kernel? Should we focus our resources on providing alternatives and again have a multitude of different Unix versions, every incompatible with each other? Isn’t it better that we have this solid foundation and make it as good as it can be?

          Overall I think standardization of init is not so bad, just like adopting the Linux kernel was. It is actually quite nice that you can hop from distro to distro and know what to expect from such a basic thing as init process.

          Anyways, in Linux land you actually have a possibility to replace it. Granted, it is not as easy, however there are plenty of distros that allow you to ditch systemd in favor of something else.

        • Jajcus@kbin.social
          link
          fedilink
          arrow-up
          3
          ·
          2 years ago

          Every major distro uses systemd, because before that it was nearly impossible to properly implement things that distros have to provide.
          Most startup scripts were incredible set of hacks to make services behave. Those were very inefficient (they could not be efficient being shell scripts calling other commands for various simple repetitive tasks) and would often break when circumstances were different from ideal.

          Systemd just makes building Linux distribution much easier, and the resulting system is more reliable, more consistent and more flexible. Why would distro developers chose anything else?

        • Thorned_Rose@kbin.social
          link
          fedilink
          arrow-up
          3
          ·
          2 years ago

          Missing my point. It’s a shitty comparison that is incredibly insensitive towards people who suffer with cancer and their friends and family.

    • Sandbag@lemmy.world
      link
      fedilink
      arrow-up
      12
      arrow-down
      4
      ·
      2 years ago

      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.

      • TCB13@lemmy.worldOP
        link
        fedilink
        arrow-up
        5
        ·
        2 years ago

        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.

      • gian @lemmy.grys.it
        link
        fedilink
        English
        arrow-up
        3
        ·
        2 years ago

        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.

      • michaelrose@lemmy.ml
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 years ago

        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.

      • Tobias Hunger@programming.dev
        link
        fedilink
        arrow-up
        14
        arrow-down
        4
        ·
        2 years ago

        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.

        • TCB13@lemmy.worldOP
          link
          fedilink
          arrow-up
          5
          ·
          edit-2
          2 years ago

          It seems that, in many people’s view, it’s better to have janky scripts starting systems, having to delegate logging management and service monitorization to the services themselves or cumbersome tools poorly used by most distros such as logrotate? Systemd offers a good thing, easy configuration and IT DOES fix a LOT of issues. People who never tried it won’t see how better it is, just try it… like I did 10 years ago.

          One of the moments where we see the true power of systemd is when we use it for containers and suddenly realize that the tools used to manage the system such as systemctl and journalctl can be used to inspect and affect a container without even having to enter it. Another equally interesting moment in the systemd journey is when you’ve an ARM system with 512MB of RAM or even less and you figure out that it will save you precious resources for other things.

        • TCB13@lemmy.worldOP
          link
          fedilink
          arrow-up
          7
          arrow-down
          1
          ·
          2 years ago

          The fact the original website is no longer available tells us a LOT about it. Maybe the server running it crashed because it didn’t have proper service monitoring… or all the init jankiness was wasting so much resources the guy paying for the server run out of money :D

          Now in all seriousness: I don’t disagree with most points however, systemd also provides a TON of functionally that was never this easy and stable. Also if you consider the grand scheme of things Docker and whatnot are a bigger virus than systemd is or will ever be and the irony is that systemd does run containers with less overhead :).