[HN Gopher] Systemd by Example
___________________________________________________________________
Systemd by Example
Author : Foxboron
Score : 285 points
Date : 2022-01-25 12:56 UTC (10 hours ago)
(HTM) web link (systemd-by-example.com)
(TXT) w3m dump (systemd-by-example.com)
| throwawaymanbot wrote:
| Anthony-G wrote:
| I just tried the first exercise of creating a default target and
| this web application is a great learning resource for Systemd. It
| should be noted that it works best as a complement to the
| author's series on _Systemd by example_ 1.
|
| I also love how the web application works without requiring
| multiple JavaScript dependencies hosted on third-party servers.
|
| 1 https://seb.jambor.dev/posts/systemd-by-example-part-1-minim...
| zibzab wrote:
| I was just wondering why everything loaded so fast and was so
| fluid...
| ghoshbishakh wrote:
| Wow wonderful set of articles. A big thanks! Wanted to understand
| this stuff for a long time but could not give enough time to
| navigate the dense documentation.
| mkaic wrote:
| I just learned the _absolute basics_ of systemd the other day
| while trying to set up an auto-restarting game server on an RPi
| for my little sibling, and finding helpful examples was extremely
| difficult. This seems like a perfect solution!
| synergy20 wrote:
| I like all those 'learnXbyexample' sites, though I really hope I
| can have a drop down menu or side-bar to access the TOC instead
| of going back to homepage each time for next subject.
| egberts1 wrote:
| folkhack wrote:
| This is outstanding... I really wish I would have had this
| learning systemd as it would have saved me _hours_. Let's be real
| - a lot of Linux fundamental stuff is still pretty terse.
| Learning tools like this really smooth it out and optimize how
| long it takes to wrap your head around a concept. Also, I am a
| _huge_ advocate for hands-on in regards to retention.
|
| Adding to my favorites and will be passing this on over the years
| - thank you for such a great resource.
| native_samples wrote:
| If anything the biggest problem the systemd docs have is
| verbosity. It's all classic UNIX man pages, a billion pages of
| detail on every possible setting with no useful examples
| anywhere. Fortunately the core system is simple enough that the
| learning curve isn't too steep but I'd really hate to try and
| learn it from the official docs. They don't even apply CSS to
| the HTML versions of the docs.
| westurner wrote:
| Wikipedia: https://en.wikipedia.org/wiki/Systemd
|
| Web: https://systemd.io/
|
| Src: https://github.com/systemd/systemd
|
| Systemd manpage index:
| https://www.freedesktop.org/software/systemd/man/
|
| https://www.freedesktop.org/software/systemd/man/systemd.htm.
| .. : man 1 systemd man systemd
| man init
|
| ...: man systemctl man journalctl
| man systemd.timer man systemd-resolved
|
| The Arch Linux wiki docs for systemd are succinct:
| https://wiki.archlinux.org/title/systemd
|
| Fedora docs > "Understanding and administering systemd"
| https://docs.fedoraproject.org/en-US/quick-
| docs/understandin...
|
| RHEL7 System Administrator's Guide > "Chapter 10. Managing
| Services with SystemD"
| https://access.redhat.com/documentation/en-
| us/red_hat_enterp...
| folkhack wrote:
| This isn't a knock but it's exactly what I was talking
| about and why I find OP's learning tool to be so valuable.
|
| Lots of folks learn by example and hands-on labs.
| Personally, I'd much rather learn the basic ropes by
| jumping into a tool like OP's vs. finding/digging through
| all of these resources. I'll also criticize to say you
| likely already know much about systemd, and were able to
| pull/filter these resources much easier vs someone
| completely new to the concepts.
|
| To illustrate further: vim is another tool that has
| outstanding learning resources, everything from very quick
| "hey get started" examples docs all the way up to adventure
| games. If I had to go back and relearn vim I would
| absolutely do it this way vs. digging on man pages like
| when I was a kid in the 90's. Personally, I learn by doing.
|
| ---
|
| Overall - OP's thingy is what I would call a "rich
| interactive learning tool." It's anecdotal, and obvious
| projection - but _for me_, interactive learning tools
| optimize the time it takes to fully "grok" a subject from
| scratch vs. jumping into a bunch of docs/man pages.
| westurner wrote:
| I often find the `## Usage Examples` heading in manages
| to be most helpful, too.
|
| ~Examples as Integration Tests as _executable_ notebooks
| with output and state _assertions_ may incur less
| technical debt.
|
| How to manage containers with [MicroShift] k8s/k3d _with
| systemd_ might be a good example.
| Foxboron wrote:
| Well, we also have a very nice manpage viewer.
|
| I think systemd.directives(7) is an often overlooked
| manpage.
|
| https://man.archlinux.org/man/systemd.directives.7
| westurner wrote:
| FWIW, the man.vim vim plugin does grep and some syntax
| highlighting. https://github.com/vim-utils/vim-man
| Arnavion wrote:
| TIL about that manpage. I've always been guessing at
| which level in the hierarchy would contain a particular
| option ("Is it service-specific? Or maybe applies to all
| execs? Or maybe applies to all units?") and just giving
| up and opening them all in parallel.
| native_samples wrote:
| Yes, the Arch docs are the best. But they aren't from the
| systemd project itself, are they?
| folkhack wrote:
| And, as a Debian user who often finds himself on the Arch
| docs - there's a ton of distro-specific stuff in the Arch
| wiki. And rightfully so - it's a wiki for a distro.
|
| These sorta landmines when trying to just research/digest
| a concept can really suck. OP's tool really eloquently
| breaks things down to _just_ core concepts so you can
| quickly start to grok what I consider to be a relatively
| complex tool.
| Arnavion wrote:
| In my experience very little of it is distro-specific,
| especially if you're on a distro that has similar
| components as Arch. I'm on OpenSUSE Tumbleweed, which
| also uses systemd, etc and is a rolling distro with the
| latest versions of everything, so a lot of the wiki
| articles apply directly as long as I translate the
| package names.
| folkhack wrote:
| Agree - but there's still bits and pieces that don't
| translate over to other distros which can suck if you're
| jumping into to learning something. When I read the Arch
| Wiki as a Debian user I realize I'm reading it through
| the lens of someone using a different distro.
|
| Overall I use the Arch wiki very often and it's because
| of the exact point you're making - I'm just being
| pedantic saying those slight distro differences can be a
| pain.
| morganvachon wrote:
| Agreed, I have generally avoided systemd as I don't feel it's
| fully baked yet (not trying to start a flame war, that is just
| my experience and I'm sure it's fine for others). Still, I need
| to really learn it both for when I am ready to use it daily and
| just to have it in my wheelhouse for supporting others. A guide
| like this seems like a great way to go "hands on" without
| spinning up an instance and fumbling through it blindly.
|
| Hopefully this guide will stay up to date given the "move fast,
| break things, wontfix" approach the systemd authors currently
| have with the project.
| Foxboron wrote:
| >Hopefully this guide will stay up to date given the "move
| fast, break things, wontfix" approach the systemd authors
| currently have with the project.
|
| The core dependency principles around targets, services and
| startup does not see a lot of change, so this concern is not
| really realistic. You'll see more of this around the
| supporting utilities (networkd, resolved, and so on).
| Klasiaster wrote:
| It's on version 250. How many stable releases do you need to
| feel that it is "fully baked"? The software is of course
| evolving and new features are added but breaking changes are
| rare.
| cies wrote:
| Since systemd I never had to learn about my init system, it
| basically just works. For to reasons.
|
| 1. On desktop the old init systems were quite good already,
| before systemd was introduced. Systemd made it better, as I've
| been told: I never had any beef with it (oh boy did I have beef
| with init systems in the old days, not only on desktop...), I did
| not do any benchmarks to see that it shaved off a few seconds in
| startup time (and helps remove lots of fragile network mgmt
| code).
|
| 2. On server I now use Docker. It has no init system. And when I
| need one I use one that fits the docker world (i.e. supervisor).
| mdaniel wrote:
| > It has no init system.
|
| Apologies that I can't link directly to the "--init" flag but
| docker actually _does_ have an init, it 's just (err, was?)
| compiled into the binary:
| https://docs.docker.com/engine/reference/commandline/run/#op...
|
| My recollection is that it either adopted, or inspired,
| https://github.com/Yelp/dumb-init#readme which folks used to
| put into their Dockerfile as the init system back in the day
|
| Folks (ahem, I'm looking at you, eks-anywhere[0]) who bundle
| systemd into a docker container are gravely misguided, and the
| ones which do so for the ability to launch sshd alongside the
| actual container's main process are truly, truly lost
|
| 0: https://github.com/aws/eks-
| anywhere/issues/838#issuecomment-...
| rmetzler wrote:
| Just the other day I noted on Twitter how bad the official
| systemd website is for users. I'm looking forward to this site
| recovering from HN hug.
| steeleduncan wrote:
| Out of curiosity, how is this implemented? Is there a javascript
| VM running in the browser, a remote VM or can systemd be run in a
| container?
| zamadatix wrote:
| There is a link to a post at the top which gives a detailed
| overview https://seb.jambor.dev/posts/systemd-by-example-the-
| playgrou...
|
| but the short of it is it creates a limited remote container
| and pipes the CLI back and forth.
| pc86 wrote:
| Site appears to be down
| BrightOne wrote:
| HN hug!
| setheron wrote:
| Wow. This is amazing. This is the bar needed for many learning
| resources.
|
| Thank you.
| mikepurvis wrote:
| Maybe slightly off topic, but I'd love to hear about people's
| experiences using systemd as process manager inside a container,
| specifically for the unprivileged container case, where systemd
| would be launched in user mode, so _only_ doing process
| management, without all the other kernel-hook stuff going on.
|
| I really like systemd, and I really don't like supervisor. So I'd
| love to figure out how to make this work.
|
| I know the easiest thing would be to ignore the user mode
| business and just use podman, where the work has already been
| done [1], but at least in the short term that doesn't help for
| more restricted environments like cloud kubernetes.
|
| [1]: https://www.redhat.com/sysadmin/improved-systemd-podman
| drran wrote:
| Systemd can be used in a docker container only when lot of
| system services are masked. See my old CentOS 6 with systemd in
| docker container project as example:
| https://github.com/vlisivka/docker-centos7-systemd-unpriv
| mikepurvis wrote:
| That's fascinating-- thanks for pointing it out. I definitely
| assumed the issue was with the daemon itself, and not with
| the services it was trying to start.
| mrweasel wrote:
| May I ask why you'd want to use a process manager inside a
| container? I just consider Docker my process manager. If my
| application crashed, Docker will deal with it.
| mikepurvis wrote:
| A valid question-- certainly there's a school of thought that
| says one process per container, end of story.
|
| However, there are lots of applications out there (especially
| legacy ones, think stuff like Zoneminder) which are made up
| of multiple small daemon-type processes sharing state across
| ports and maybe even the filesystem, and have a strong
| reliance on system services like cron or log rotation. Yes,
| with effort an application like this could be be fully
| "ported" to a container-native setup, but the path of least
| resistance is often to just make the container environment
| present as being more like a full VM.
| tifadg1 wrote:
| I've reverted from podman to docker as the podman ecosystem
| isn't there - docker-compose, cadvisor, some networking - all
| require tinkering to run.
|
| My interim solution is running docker containers as user, using
| a simple USER directive. Straightforward and still added
| security benefits.
___________________________________________________________________
(page generated 2022-01-25 23:01 UTC)