A systemctl and journalctl compatibility layer for Linux systems that do not run systemd.
On Artix, Void, Devuan, Alpine, Gentoo, Chimera and similar distributions, third-party packages and scripts, from AUR for example, still call systemd tools while installing/upgrading packages, and you get into your terminal something like this:
/tmp/alpm_jKVKZ5/.INSTALL: line 58: systemctl: command not found
fake-systemd is a single static, multi-call binary written in Zig. Invoked as systemctl or
journalctl, it follows the systemd command-line contract (verbs, options, output, exit codes) and
drives the init that is actually running. systemd units are translated into the init's native service
format on first use, so systemctl enable --now foo ends up as a real service of your init.
It does not implement D-Bus, socket activation, cgroups, sandboxing, or the other systemd tools
(systemd-tmpfiles, systemd-sysusers, ...).
| Init | System services | User services |
|---|---|---|
| dinit | supported | yes (dinit --user) |
| runit (Void, Artix) | supported | with turnstile |
s6-rc (Artix with the s6 frontend; elsewhere compiled from source directories) |
supported | no |
| s6 (scan directory without s6-rc) | supported | no |
| OpenRC (Alpine, Gentoo, Artix) | supported | 0.60 or later with openrc-user |
| sysvinit (Devuan, Debian, Red Hat family) | supported | no |
| BSD-style rc (Slackware) | supported | no |
| procd (OpenWrt) | supported | no |
| 66 (Obarun; 0.9 and later) | supported | yes |
BusyBox init (with runsvdir in the inittab, or with init scripts) |
supported | no |
| finit (4.x) | supported | no |
GNU Shepherd (outside Guix System; on Guix System enable and disable only warn) |
supported | yes |
| nosh (delegates to its unit converter) | experimental | no |
git clone https://aur.archlinux.org/fake-systemd-bin.git
cd fake-systemd-bin && makepkg -siThe package provides systemctl and conflicts with systemd.
The AUR package above is the recommended path; it installs into /usr/bin.
Each release at https://github.com/0cool-f/fake-systemd/releases ships static tarballs
fake-systemd-<version>-<target>.tar.gz for x86_64-linux-musl, aarch64-linux-musl,
arm-linux-musleabihf, riscv64-linux-musl and x86-linux-musl, plus SHA256SUMS signed with
cosign (keyless, Sigstore). Verify, then install:
version=0.1.0
target=x86_64-linux-musl
base=https://github.com/0cool-f/fake-systemd/releases/download/v$version
curl -fLO "$base/fake-systemd-$version-$target.tar.gz"
curl -fLO "$base/SHA256SUMS"
curl -fLO "$base/SHA256SUMS.sigstore.json"
cosign verify-blob \
--bundle SHA256SUMS.sigstore.json \
--certificate-identity "https://github.com/0cool-f/fake-systemd/.github/workflows/release.yml@refs/tags/v$version" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
SHA256SUMS
sha256sum --check --ignore-missing SHA256SUMS
tar -xzf "fake-systemd-$version-$target.tar.gz"
doas cp -P "fake-systemd-$version-$target"/{fake-systemd,systemctl,journalctl} /usr/bin/The tarball also contains LICENSE and this README.md. systemctl and journalctl are symlinks
to fake-systemd.
Install into /usr/bin, not /usr/local/bin, for two reasons:
- The generated services run the executor as
/usr/bin/fake-systemd, a path that is fixed in the generated files, so a copy only in/usr/local/binleaves them without their executor. - The caller of
systemctlmay not have/usr/local/binin itsPATH. Package managers do not agree on thePATHof their scripts. apk runs package scripts withPATH=/usr/sbin:/usr/bin:/sbin:/binunless--preserve-envis given (src/context.cof apk-tools). The sources of libalpm (pacman scriptlets, 7.1.0), dpkg (maintainer scripts) and xbps (INSTALL and REMOVE scripts) do not setPATH, so those scripts get the one of the process that runs the package manager, which may leave out/usr/local/bin. Init scripts may run with a reducedPATHas well; that was not checked.
systemctl daemon-reload
systemctl enable --now foo.service
systemctl is-active foo
systemctl status foo
systemctl restart foo
systemctl disable --now foo
systemctl list-unit-files
systemctl list-timers
journalctl -u foo -n 50
journalctl -u foo -fOffline work on another root (chroots, image builds):
systemctl --root=/mnt/target enable foo--version prints the fake-systemd version and the detected backend.
start and restart of a Type=forking unit with PIDFile= return once the daemon named in the pid
file is recorded as the main process, as they do in systemd, and fail when TimeoutStartSec= runs out
first. The init scripts and procd wait in their own scripts; for the supervisors that run the
executor (runit, s6, shepherd, ...) fake-systemd waits itself.
A unit is translated to the init's native format only when a verb needs it (Translate=lazy);
daemon-reload translates every candidate with Translate=eager. A native service that already
provides the same functionality (same name or alias, and the same executable) is used instead of
generating one. A native service that has the name of the unit but runs another program is a conflict:
enable fails and asks for an entry in [Aliases]. Units that cannot be translated are reported as
unsupported in list-unit-files.
Every generated file starts with a header block (Generated automatically by fake-systemd...) that
records the unit, its source and content hashes. An index under /var/lib/fake-systemd/<backend>/
($XDG_STATE_HOME/fake-systemd/ for --user) tracks generated files and can be rebuilt from the
markers.
Local edits to generated files are kept. When both you and a package changed a file, your file stays
and the new version is saved as .fsnew under /var/lib/fake-systemd/backup/<backend>/; when the
source unit is removed but the file was modified, it is moved there as .fssave. Removing the header
block makes the file yours: fake-systemd no longer touches it.
--dry-run (or FAKE_SYSTEMD_DRY_RUN=1, for scripts you cannot edit) runs the whole pipeline without
writing anything or contacting the init. It prints a unified diff for each file that would change and
the init commands that would run:
systemctl --dry-run enable foo.timer units are managed with the usual verbs. For each enabled timer fake-systemd picks a
scheduler: a native cron (cronie or Debian cron through /etc/cron.d, dcron and BusyBox crond
through the root crontab, fcron) when the schedule translates exactly, otherwise a built-in runner
(fake-systemd-timers, a service supervised by the init). Both run the same job, so logs,
journalctl -u and list-timers behave identically. --user timers always use the built-in runner.
Services that fake-systemd generates log to one place whatever the init is, and journalctl reads it.
There is no binary journal.
- System services log to
/var/log/fake-systemd/<unit>/current, user services to$XDG_STATE_HOME/fake-systemd/log/<unit>/(~/.local/statewhen unset). - A line is plain text,
2026-10-24T12:05:01.123+02:00 <message>: ISO 8601 with milliseconds and the local offset (TZ, else/etc/localtime, else UTC). fake-systemd --log <unit>does the writing and the rotation. Whencurrentplus the next line would exceed 1 MiB,currentbecomes@<unix seconds>.login the same directory, and at most 10 files are kept,currentincluded. Aflockon.lockkeeps concurrent loggers from rotating twice.- The directory of a unit is created with mode 0750 and
currentand.lockwith 0640, both subject to the umask; there is nochown. fake-systemd --logis the logger of the runit and s6 services (log/run, the logger service of s6-rc), and OpenRC passes it tosupervise-daemonasoutput_loggeranderror_logger. Where nothing supervises a logger (sysvinit, BSD-style rc, BusyBox with an inittab, procd, 66, finit, Shepherd), the executor started withfake-systemd --exec <unit> --logstarts it.- Two backends write the raw output of the service to
currentinstead, with no timestamp and no rotation: thelogfileof dinit, andoutput_loganderror_logof OpenRC before 0.51.journalctlgives such a line the timestamp of the one before it. The services of nosh log where nosh sends them, sojournalctl -ushows nothing for them.
journalctl merges the logs of the selected units by timestamp, in the short format (Oct 24 12:05:01 host unit: message) or cat. It supports:
-u/--unitand--user-unit(repeatable, globs allowed) and the matches_SYSTEMD_UNIT=and_SYSTEMD_USER_UNIT=; without a selection, the logs of every system unit. Other matches are ignored with a warning.-n(a number orall),-e(the last 1000 lines),-f(shows 10 lines unless-nsays otherwise, then follows new lines and rotation),-o short|cat,-q,--no-hostname,--no-pager(nothing is paged anyway), and-k, which runsdmesg.--sinceand--untilwithnow,today,yesterday,tomorrow,@<unix seconds>, relative times (-1h,+5min,5 min ago,1h left), andYYYY-MM-DD[ HH:MM[:SS[.fff]]]orHH:MM[:SS](the current day), in the local zone unless followed byUTC.-b, which means the entries since the boot time that/proc/statreports.-b <id>for any other boot says that only the current boot is kept and shows nothing.- For a unit named with
-uthat has no uniform log, the native log files of the init's profile: a file per service is shown whole, a shared file only for its lines that mention the service. Those lines are printed as they are and dated by the modification time of the file. When nothing is found, a notice lists the locations that were checked.
It does not read /run/log or any journal file, has no pager, knows no boot ids, and rejects other
options (--user, -p, -o json, ...) as unknown or invalid.
Project: davmac314/dinit.
A unit becomes one service description file, named after the unit (foo.service becomes foo), in the
directory of its tier: /etc/dinit.d for administrator units, /usr/lib/dinit.d for vendor units
(/usr/local/lib/dinit.d when the unit comes from /usr/local), and /run/dinit.d for runtime units
when it exists. User services go to $XDG_CONFIG_HOME/dinit.d, or to /etc/dinit.d/user,
/usr/lib/dinit.d/user and /usr/local/lib/dinit.d/user for the units of those tiers.
enable does not run dinitctl enable, which also starts the service. It writes the link that
command writes, <name> in the directory that the waits-for.d setting of the boot service names
(/etc/dinit.d/boot.d when the boot service cannot be read, ~/.config/dinit.d/boot.d for a user): a
relative link ../<name> when the file sits next to that directory, otherwise the path of the file.
This is the same online and offline. enable --runtime with dinit running uses
dinitctl --quiet add-dep waits-for boot <name> (disable --runtime uses rm-dep); without a running
dinit it warns and enables persistently. disable does not stop the service, and is-enabled is
whether the link exists. Verified with a real dinit (not PID 1) in a Chimera container, where
dinit-check accepts the generated files; the states of dinitctl status that the unit tests map were
observed with dinit 0.22. The image installs the package of Chimera without a pinned version.
Type=simpleistype = process,Type=oneshotisscripted, andType=forkingisbgprocesswithpid-filewhen it hasPIDFile=,scriptedwhen it does not (the daemon is started and not supervised, which the file says in a comment), andprocessunder the executor.Type=notifyreadiness is not emitted.Requires=andBindsTo=becomedepends-on,Wants=waits-for, andAfter=andBefore=afterandbefore. Units that a unit requires or wants are translated with it.network.targetbecomes the first service that exists ofnetwork.targetandnetwork, andnetwork-online.targetthe first ofnetwork-online.target,network-online,networkandnetwork.target. The enabled network providers (dhcpcd,NetworkManager,connmand,iwd,wpa_supplicant,netctl) are added aswaits-for. Other targets are dropped.- The command is
ExecStart=when dinit can run it as it stands, else the executor (fake-systemd --exec <unit>).Environment=becomes/usr/bin/env NAME=VALUE .... Settings that need the executor includeExecStartPre=,ExecStartPost=,EnvironmentFile=,Group=,SupplementaryGroups=,UMask=, the*Directory=settings, mostLimit*=and variable expansion;LimitNOFILE=,LimitCORE=,LimitDATA=andLimitAS=becomerlimit-*. - Logging: every file has
logfile = <log directory>/currentwithlogfile-permissions = 640, so dinit writes the raw output of the service there, even under the executor: no timestamps and no rotation, andjournalctlgives each line the timestamp of the one before it. The log directory of a service and of the services it pulls in is created bystart,restartand byenablewhen it writes a new link, since dinit does not create it. - Identity: for a native command with
User=in system scope,run-asandload-options = export-passwd-vars, so dinit looks the account up with its libc. When the executor runs the unit it does the switch itself: from/etc/passwdand/etc/groupfor an account it can read, otherwise (LDAP, sssd) with numeric ids that a/bin/sh -cwrapper looks up withidwhen dinit starts the service, the executor staying root. User services have norun-as. Restart=becomesrestart = false,true(always, andon-successapproximated, which the file says in a comment) oron-failure(the other variants), withsmooth-recovery = trueandrestart-delayfromRestartSec=. Ascriptedservice always hasrestart = false.ExecStop=of a oneshot isstop-commandwhen it is one plain command, and every otherExecStop=orExecStopPost=runs throughstop-commandwith the executor (--phase stop).TimeoutStartSec=andTimeoutStopSec=becomestart-timeoutandstop-timeout;KillSignal=,Nice=andNoNewPrivileges=becometerm-signal,niceandoptions: no-new-privs.- Templates: dinit reads
name@argas an instance of the filename@, sogetty@tty1.servicebecomes the servicegetty-tty1with a file of its own, and characters outside letters, digits,.,-and_in the instance become_. stopusesdinitctl stop --force.restartstarts a service that is stopped, whichdinitctl restartrefuses. dinit has no reload action:reloadruns the executor with--phase reloadfor a generated service and fails for a native one.daemon-reloadrunsdinitctl reloadon the loaded services that fake-systemd generated. Power verbs runshutdown -r,-pand-h.- User services run in
dinit --user(dinitctl --user). They are covered by the unit and golden tests, not by the end-to-end test, which has no user instance of dinit. - Not emitted:
Conflicts=,PartOf=, socket activation,env-fileandready-notification.KillMode=noneandmixedare handled likecontrol-group.
Project: smarden.org/runit.
A unit becomes a service directory with run, log/run, and when the unit needs them finish,
control/t and fake-systemd.meta: in /etc/sv on Void and in /etc/runit/sv on Artix, or in
~/.config/sv for a user (the other distributions use the layout of Void). enable links the directory
into /etc/runit/runsvdir/default, which /var/service (Void) and /run/runit/service (Artix) point to
through runsvdir/current, and which also exists in a chroot. runsvdir starts everything it finds, so
the service is enabled when the link exists and the directory has no down file: enable creates the
link and removes down. start of a service that is not enabled links it with a down file, so it does
not start at boot, and the link stays after stop; the services that run starts (Requires=,
BindsTo=, Wants=) are linked with down as well, since runsvdir supervises them but does not start
them. disable of a running service writes down and keeps the link, because removing the link makes
runsvdir stop the service; otherwise it removes the link and waits up to 8 s for the runsv to go.
is-enabled is a link without down. enable never calls sv, and --runtime is not supported: it warns
and enables persistently. Verified with a real runsvdir (not PID 1) in a Void musl container; the Artix
layout is covered by the profile tests only, and the version of runit is that of the Void repository.
- Dependencies are lines at the top of
run.Requires=andBindsTo=becomesv start <dep> || exit 1, andWants=and the enabled network providerssv start <dep>whose result is ignored (SVDIR=<dir> sv startfor a user).After=andBefore=are not expressed, and the network targets map to nothing but those providers.startandstopgiveTimeoutStartSec=andTimeoutStopSec=(90 s for a stop without it) tosv -w. - Logging:
log/runisexec /usr/bin/fake-systemd --log <unit>, andrunstarts withexec 2>&1, so the uniform log has timestamps and rotation. The native logs thatjournalctlfalls back to are/var/log/<name>/current. - Identity: an account that the executor can read from
/etc/passwdand/etc/groupruns under the executor, which switches itself. For an account only the system libc knows (LDAP, sssd), a native command is run withsetpriv --init-groups, or withchpst -uand a warning whensetprivis not installed, sincechpstapplies no supplementary groups; under the executor the scripts look up numeric ids withidand pass them as--uid,--gidand--groups. The executor also runs every oneshot, everyType=forking, and every unit withLimit*=,*Directory=,ExecStartPre=orExecStartPost=. A oneshot withRemainAfterExit=yesruns its command and thenexec sleep 2147483647. Restart=:runsvrestarts a service after every exit, soRestart=alwaysneeds nofinish. The others, a oneshot,ExecStopPost=and aRestartSec=of 2 s or more (up to 24 h) get afinishthat records how the process ended insupervise/exit-status(statusreadsfailedfrom it), runsExecStopPost=through the executor, sleeps forRestartSec=, and keeps the service down (sv down .) after the exits thatRestart=does not restart on;runsvmay read that byte after it has reapedfinish, so it only sets what is wanted and never starts the service.restartis a stop and a start, becausesv restartwould ignore whatfinishdecided.ExecStop=iscontrol/t: it runs the executor with--phase stop-mainand the pid of the main process asMAINPID. WithoutExecStop=, aKillSignal=other thanSIGTERMis acontrol/tthat sends it to the pid insupervise/pid.reloadrunsExecReload=through the executor, orsv reloadfor a service that was not generated. Power verbs runrunit-init 6(reboot) andrunit-init 0(poweroff and halt).- Templates keep their name:
foo@bar.serviceis the directoryfoo@bar, whichrunsvdirandsvaccept. - User services need turnstile with its runit backend, detected from
/usr/libexec/turnstile/runitandbackend = runitin/etc/turnstile/turnstiled.conf. Services are generated in~/.config/svand linked into~/.config/service, or into theservices_dirof/etc/turnstile/backend/runit.conf, andsvis given the path of the link. The end-to-end test runs arunsvdirper user by hand with a stub of the turnstile files, not turnstile itself. - Limits: no ordering without a dependency (
After=,Before=), no--runtime, and user services only with turnstile.
Projects: skarnet/s6 and skarnet/s6-rc.
A unit becomes the source directories of an s6-rc longrun foo-srv whose output feeds the logger
foo-log of a pipeline named foo (a oneshot unit becomes an s6-rc oneshot with up and down in
execline), or, on plain s6, a service directory linked into the scan directory. On Artix the s6
frontend does the work: enable runs s6 repository sync, s6 set enable -p, s6 set commit and
s6 live install. Elsewhere enable lists the service in the boot bundle default and builds a new
database with s6-rc-compile, which s6-rc-update moves the running system to; daemon-reload
builds it again.
- On plain s6,
startrescans the scan directory and waits, up toTimeoutStartSec=, untils6-superviseof the service and of its linked dependencies is ready, and fails when it never appears.stopwaits forfinishto end (s6-svc -wD,s6-svwait -Don s6-rc). - s6-rc has one kind of dependency, so
Wants=and the network providers become dependencies likeRequires=. With the Artix sets an enabled service pulls its dependencies into the set, so they are enabled too. - Offline in the real root (
--root=/) the database is built without touching a live one; inside another root only the sources are written and the database is left for the target. - A service with
ExecStop=runs under the executor, which stays resident and runs the stop commands when it gets SIGTERM, so they run on every stop:systemctl stop, s6-rc stopping the service as a dependent, a shutdown. (On plain s6 a oneshot that holds after its command gets them fromsystemctl stoponly.) - A oneshot without
RemainAfterExit=runs again at eachstart: s6-rc brings it down first, which also stops the services that depend on it. - There are no user services.
Project: OpenRC/openrc.
A unit becomes an openrc-run script in /etc/init.d (foo@bar.service becomes foo.bar), and
enable adds a link to it in the default runlevel with rc-update. Verified on Alpine (OpenRC
0.63.2), Gentoo (0.63.3), Artix (0.64.1) and Devuan (0.45.2). Units with Restart= run under
supervise-daemon, with the output going to the uniform log through output_logger and
error_logger. The others run their executor under start-stop-daemon with a pid file of its own;
the executor logs the output of the service itself and records how the main process ended, so the
service does not depend on what start-stop-daemon can do (the one of dpkg can do little). start
returns once the executor recorded the main process or the end of the service, and fails when it dies
first or TimeoutStartSec= runs out.
Requires=andBindsTo=becomeneed,Wants=becomeswant,After=andBefore=becomeafterandbefore, and the network targets becomeuse netanduse network-online. OpenRC starts the services a script needs itself, so they are not enabled.supervise-daemonrespawns on every exit, soRestart=on-failureand its variants restart after a clean exit too.- OpenRC records a service whose process is gone as started and crashed. For a service without
Restart=,statusreads the file its executor wrote: a clean end (orSuccessExitStatus=) isinactive, anything else, and a death without a file, isfailed. A service thatsupervise-daemongave up on isfailedas well. - A oneshot stays started in OpenRC;
statusreads it as inactive unlessRemainAfterExit=yes, and eachstartruns it again. - A service with
ExecStop=runs under the executor, which stays resident and runs the stop commands when it gets SIGTERM, so they run on every stop:systemctl stop, a runlevel change, a shutdown. User=andGroup=usecommand_userundersupervise-daemon, which applies the groups of the account. An account the executor cannot read from/etc/passwd(LDAP, sssd) reaches the executor as numeric ids (--uid,--gid,--groups) that the script looks up withidandgetent; the executor stays root and switches itself.- OpenRC reads dependencies from a cache that it does not rebuild when a script appears, so
startandrestartrunrc-update -ufirst when the script directory is newer than the cache. - User services need OpenRC 0.60 or later with a user session (
openrc-user).
Project: slicer69/sysvinit.
A unit becomes an LSB init script in /etc/init.d (foo@bar.service becomes foo.bar) with the LSB
header that insserv reads, and on Red Hat the chkconfig: header as well. enable links it with
update-rc.d <script> defaults on Debian and Devuan and with chkconfig <script> on on Red Hat, and
is-enabled looks for a start link in the default runlevel: the initdefault of /etc/inittab, else 2
on Debian and 3 on Red Hat. The scripts have the actions start, stop, restart, try-restart,
reload, force-reload and status, and answer status with the exit statuses of the LSB (0 running,
1 dead with a pid file, 3 not running). Verified with sysvinit as PID 1 on Devuan 5 (sysvinit 3.06,
insserv 1.24.0, dpkg 1.21.23) and Debian 13 (sysvinit 3.14, insserv 1.26.0, dpkg 1.22.22). The Red Hat
family is verified on Rocky Linux 10 (chkconfig 1.30, initscripts 10.26) and 9 (chkconfig 1.24,
initscripts 10.11.8), which boot systemd: no sysvinit runs there, so the tests stand in a process
named init and the control socket for it. The /etc/rc.d/rc of a sysvinit system (CentOS 6,
initscripts 9.03.61) was read for the lock files, not run.
- Every service runs under the executor, which logs, records how the main process ended in
/run/fake-systemd/<unit>.exit, and turns SIGTERM into the stop, soExecStop=runs whenever the script stops the service:systemctl stop, a runlevel change, a shutdown. A daemon is started in the background bystart-stop-daemonon Debian and byfake-systemd --exec <unit> --daemonon Red Hat, and its executor pid is in<unit>.daemon.pid;<unit>.pidholds the main process.startreturns once the executor recorded it, or the end of the service, and fails when the executor dies first orTimeoutStartSec=runs out. - sysvinit supervises nothing:
Restart=is not honored, and a service that dies stays dead.statusreadsfailedfor it (the script says it is dead and not restarted), which is also how a timer runner that died shows, since the runner is such a service. A oneshot runs to the end instartand isinactiveafterwards, oractivewithRemainAfterExit=yes; aType=forkingservice withoutPIDFile=is that kind of oneshot, which stop cannot signal. Requires=andBindsTo=are named in a# Pulls-In:line, andenableenables those scripts with the service (daemon-reloaddoes for a requirement added later).After=andWants=only order. On Debian every unit a unit follows, wants or requires isShould-Start:insservstops with a fatal error at aRequired-Startthat names a script that is not enabled, and then at every later run for any script. Red Hat'schkconfigsorts byRequired-StartandShould-Startalike and ignores a missing script, so the hard dependencies areRequired-Startthere.Before=isX-Start-Before, whichinsservhonors andchkconfigdoes not. The network targets are the$networkfacility, and the filesystems$remote_fs.update-rc.dcallssystemctlforenableanddisablewhen one is installed, andchkconfigdoes for a script that has a unit of the same name; both would call this program, so they run with_SKIP_SYSTEMD_NATIVE=1andSYSTEMCTL_SKIP_REDIRECT=1.- Offline, in a chroot or a container build, the tools are used as they are online, since they write
the links without an init. For another
--rootthey cannot be called, and the links are written directly: late start links and early stop links (80 and 20, or the priorities ofchkconfig:), whichinsservorchkconfigsort at their next run. - On Red Hat a start creates
/var/lock/subsys/<script>and a stop removes it, because/etc/rc.d/rcruns a stop link only for a script that has one. policy-rc.dis consulted byinvoke-rc.dand by the maintainer scripts of packages, not bysystemctl, which does not consult it with systemd either.systemctl startstarts the service whereinvoke-rc.dis denied; offline, nothing starts in any case.- The presence of a
/run/initctlsocket does not mean an init is running unless PID 1 is aninit: container images keep one where nothing runs, and systemd offers a socket of that name. - Power verbs run
shutdown -r now,shutdown -h -P nowandshutdown -h -H now, which go through the stop links of runlevel 6 and 0. - There are no user services.
Project: Slackware init.
A unit becomes the script /etc/rc.d/rc.<name> (foo@bar.service becomes rc.foo.bar), which takes
the verbs start, stop, restart, reload and status and answers status with the exit statuses
of the LSB. Slackware has no mechanism for a new service: rc.M starts a fixed list of scripts and then
rc.local, and rc.6 runs rc.local_shutdown stop before it stops a fixed list. So enable sets the
execute permission of the script, which is what enables a script of the system, and writes a managed
block (# BEGIN fake-systemd ... # END fake-systemd) in rc.local that starts the enabled generated
scripts, ordered by their dependencies. A block in rc.local_shutdown stops every generated script in
the opposite order, enabled or not, so that a service started by hand or as a requirement runs its
ExecStop= at the shutdown too. A script that is not executable is disabled, and start runs it
through sh. A native script that rc.M already starts, such as rc.syslog, is enabled by the
permission alone; for another one enable warns that nothing starts it. Verified with sysvinit 3.01 as
PID 1 on Slackware 15.0 (aclemons/slackware:15.0, a rolling image pinned by digest, with the packages
of the release installed by slackpkg): a boot starts the enabled services from rc.local, and
systemctl poweroff runs their stop commands through rc.local_shutdown.
- Every service runs under the executor, as with sysvinit: it logs, records how the main process ended
in
/run/fake-systemd/<unit>.exit, and turns SIGTERM into the stop. A daemon is detached withfake-systemd --exec <unit> --daemon. Nothing supervises it:Restart=is not honored, and a service that dies readsfailed. A oneshot runs to the end instart, and isinactiveafterwards, oractivewithRemainAfterExit=yes, whoseExecStop=runs at the shutdown. Requires=,BindsTo=andWants=are scripts thatstartruns first, a failure of the first two failing the start.After=andBefore=only order the blocks. The network targets map to nothing:rc.localruns afterrc.inet1andrc.inet2.- The state of a native script is the process of its pid file, else a process named like the program
it starts, since these scripts have no
statusverb. - An account the executor cannot read from
/etc/passwd(LDAP, sssd) reaches it as numeric ids (--uid,--gid,--groups) that the script looks up withidandgetent; the executor stays root and switches itself. - Power verbs run
shutdown -r now,shutdown -h -P nowandshutdown -h -H now, which go throughrc.6. - There are no user services.
Project: openwrt/procd.
A unit becomes an init script /etc/init.d/<name> that starts with #!/bin/sh /etc/rc.common and
sets USE_PROCD=1, and enable runs /etc/init.d/<name> enable, which writes S<START><name> and
K<STOP><name> in /etc/rc.d. Without an init the links are written directly: the script cannot run,
since its procd library takes a lock in /var/lock. Verified on the OpenWrt 25.12.5 root file system
(openwrt/rootfs, procd as PID 1 started by /sbin/init in a rootless container): a boot starts the
enabled services from their start links, and systemctl poweroff runs their stop commands through the
stop links.
- A daemon is an instance that
start_serviceregisters with procd, which supervises it and respawns it asRestart=andRestartSec=say (procd_set_param respawn 10 <RestartSec> 5). procd respawns on every exit, soRestart=on-failureand its variants restart after a clean exit too. The command is the executor,fake-systemd --exec <unit> --log, because procd can send the output of a service to its log daemon but not to a file; the executor also switchesUser=andGroup=and applies the limits, so procd's ownuserparameter, which would drop the privileges the executor needs for the log directory, is not used.statusis whatubus call service listsays:active,failedafter an instance exited with an error,inactiveotherwise. procd_killreturns before the instance is gone, so the script waits for it inservice_stopped(up toTimeoutStopSec=and the grace of the executor):ExecStop=andExecStopPost=have run whenstopreturns, and procd does not go on with the shutdown before they did. procd runs the stop links only, so every generated script has one,disableleaves it, and a service that was started by hand or as a requirement stops with the others. The stop links of scripts that are gone leave atdaemon-reload.Requires=,BindsTo=andWants=are scripts thatstart_servicestarts first, a failure of the first two failing the start.STARTfollows the scripts a unit requires, wants or follows (one more than the greatest) and precedes those it is before;STOPis100 - START. The network targets are satisfied by the defaultSTART=50, afternetwork(20).- A oneshot has no instance, so its script defines
start,stop,statusandrunningitself and keeps the state in the files of the executor, as the sysvinit scripts do.EnvironmentFile=paths areprocd_set_param file, so thatreloadrestarts the instance when a file changed.ExecReload=isreload_service; without itreloadsays so, and does not restart. - OpenWrt uses musl, which reads accounts from
/etc/passwdand/etc/grouponly, and has nosetpriv: the executor switches every account it can find there, and the script says so when it cannot. - BusyBox applets are links to one binary: the normalization of executables keeps their names, or
/bin/sleepwould be taken for thecrondof the system. - Power verbs run
reboot,poweroffandhalt, which signal procd. - There are no user services.
Project: Obarun/66.
A unit becomes a frontend file in 66's own format: /usr/share/66/service for a vendor unit,
/etc/66/service for an administrator unit, ~/.66/service for a user unit (root writes the user
directories of the system, /usr/share/66/service/user and /etc/66/service/user, an account that is not
root cannot, and gets the personal directory for every tier). enable runs 66 enable -P, which parses
the frontend file into the default tree and enables the service alone, without the dependencies 66 would
enable and the dependents it would disable; 66 start starts a dependency that is not enabled anyway.
Verified on 66 0.9.1.2 with oblibs 0.4.0.1 (built from source on Alpine 3.24, where nothing packages 66)
as PID 1 (66 boot -c), after a restart of the container, at shutdown, and offline. Releases before
0.9.0.0 name the Timeout keys differently and are not supported.
- Every service runs through the executor:
[Start] Executeis a shell script that execsfake-systemd --exec <unit> --log, and 66's own logger is off. A logger of 66 reads a pipe that only its own66-executecan obtain, so a program that writes the uniform log cannot take its place, and66 logand the log lines of66 statusare empty;journalctlreads the uniform log as everywhere. - The restart policy is the exit status of
finish: 125 tells66-supervisenot to start the service again.finishreads how the process ended from66 runstate, which also givessystemctl statusits state: a process that ended by itself without a clean exit isfailed, one thatstopor the shutdown ended isinactive.Restart=alwayshits the crash budget of 66 (5 deaths in 30 s) as systemd hits its start limit. Wants=is expressed likeRequires=: 66 has one kind of dependency, which starts the dependency first and stops the service before it. A dependency is a service that 66 finds as a frontend file, so requirements are generated before the unit that needs them.- 66 0.9.1.2 does not deliver
66 signaland66 reloadto a service that is up (skipping already up service), sokillandreloadsignal the pid that66 runstatereports, and a crash-looping service that66 stopdoes not catch between two runs is held down through its control fifo (66-svctl). - 66 runs what it parsed, so a frontend file that was generated again is parsed again before the service
starts and at
daemon-reload; parsing resets the enabled state, which is set again afterwards, and a service whose frontend file is gone is removed from 66. - 66 replaces
@U,@H,@Iand the like anywhere in a frontend file and has no escape: such a name in a command or an instance (foo@Home) is kept out of the file, and in a description it reads(at)U. - Inside a
--roottree 66 cannot run (its state is compiled under/var/lib/66), soenableanddisableare refused there, andis-enabledanswers from the resolve files. Type=notifyis ready when the process starts, and66 startwaits for no more.
Project: BusyBox init.
BusyBox init runs the entries of /etc/inittab and has no control interface: nothing starts or stops one
entry, and a respawn entry would be started again when it is stopped. The backend therefore serves what
the system runs next to init:
- With
runsvdirin the inittab (BusyBox built with the runit applets, which the stock builds of Alpine, Debian and Void leave out) the services are runit service directories, served by the runit backend with the directory thatrunsvdirscans taken from the inittab (/var/serviceby default) and thesvapplet of BusyBox behind an adapter: its messages differ, and it looks in/var/serviceunlessSVDIRsays otherwise, which a generatedrunthat starts a requirement is told when the directory is another.finishthere brings a service down with the plainsv down ., without the guard of runit'sfinish. Supervision, logger per service and restart policy are those of runit. - Without it the services are the init scripts of the sysvinit backend (Red Hat flavour, whose scripts run
the executor in the background with
--daemon), andenablelists the script in a block of the inittab:::wait:entries at boot, in dependency order, and::shutdown:entries in the reverse order. BusyBox runs neither on a reload of the inittab, so changing the block starts and stops nothing; the backend sends init a SIGHUP so that its shutdown entries are current. A requirement is listed with the service, and before it. Nothing supervises the services:Restart=is not honored and a service that dies readsfailed. - The mode is read from the inittab when the backend is built. Power verbs run the
reboot,poweroffandhaltapplets, which make init run theshutdownentries. Withrunsvdir, init would signal every process at once, and arunsvthat sees its service die first never runsExecStop=, so the backend keeps a# BEGIN fake-systemdblock in the inittab with::shutdown:sv -w 90 force-stop <scan directory>/*while a service is linked:svstops the services,ExecStop=included, before init signals anything. - Verified with BusyBox 1.37.0 built from the release tarball, as PID 1 in a container, after a restart, at shutdown and offline, in both modes.
- There are no user services, and a native
respawnentry of the inittab is not seen as a native service.
Project: finit-project/finit.
A unit becomes /etc/finit.d/available/<name>.conf (foo@bar.service becomes foo-bar) with one
service stanza (a task for a oneshot), and enable links it into /etc/finit.d/enabled, which
finit loads at boot. Dependencies are start conditions: Requires= and BindsTo= become
<service/dep/running> (<task/dep/success> for a oneshot), enabling a service also enables the
services its conditions name, and network-online.target becomes <net/route/default>. Finit loads a
service only from a file it read at a reload, so systemctl start on a service that is not enabled links
it into /run/finit/system and reloads, and systemctl stop removes the link again. Verified with finit 4.12 (Debian
13) as PID 1 in a rootless container.
- The command of every stanza is the executor, which logs to the uniform location and applies the unit
settings, so finit supervises it:
Restart=becomesnorestartorrestart:always(finit restarts after any exit, soon-failureis approximated),RestartSec=restart_sec:,TimeoutStopSec=kill:(1 to 60 s) andKillSignal=halt:.ExecStop=runs when finit signals the service, andExecStopPost=and the removal of runtime directories run in a<name>.stop-postscript. - Finit has no soft dependencies and no ordering without dependency:
Wants=andAfter=are not expressed.initctl reloadstarts what is newly enabled and restarts what changed, sodaemon-reloaddoes both.Type=forkingwithoutPIDFile=is a task, started but not supervised. User services are not supported. Finit's@useroption sets no groups, so an account the executor cannot read from/etc/passwdreaches the executor as numeric ids (--uid,--gid,--groups) that a script looks up withidandgetent; the executor stays root and switches itself. - Finit kills the process group of a service when its process ends, so the last lines the logger still holds can be lost when a service exits at once.
Project: shepherd/shepherd.
A unit becomes /etc/shepherd/available/<name>.scm (~/.config/shepherd/available for a user), Scheme
that registers one service, and enable links it into init.d, which the configuration of shepherd
loads at startup and starts. When /etc/shepherd.scm (~/.config/shepherd/init.scm) does not exist it
is written with that loader; one that does not mention init.d is left alone and the loader is written
beside it. The marker is inside a #! ... !# block comment, which Guile skips. Requires= becomes
#:requirement, Restart= #:respawn? and #:respawn-delay, a oneshot a #:one-shot? service whose
start runs the executor to the end, and RemainAfterExit= a service that stays started. start of a
service the daemon does not know loads its file with herd load root, and a service Shepherd disabled
after its process died is enabled again first. Verified with shepherd 1.0.3 (Debian 13) as a daemon
of a rootless container, restarted to see the enabled services start, and with herd stop root to see
the stop hooks run.
- On Guix System the services come from the operating-system declaration:
enableanddisablewarn that it has to change and do nothing else,start,stopandstatuswork. That case was not run: the executor is expected at/usr/bin/fake-systemd, which Guix System does not have. - The command is always the executor.
ExecStop=runs when the destructor signals the executor alone,ExecStopPost=when the service is stopped, not when its process ends by itself. Shepherd has no soft dependencies and no signal action:Wants=is not expressed andkillsignals the main process.#:usersets neither group nor supplementary groups, so an account the executor cannot read from/etc/passwdreaches the executor as numeric ids (--uid,--gid,--groups) that a shell looks up when the service starts; the executor stays root and switches itself.
Project: jdebp/nosh.
fake-systemd translates nothing itself. A unit becomes a record in /etc/service-bundles/fake-systemd
that names the unit and the directory it is in, and system-control convert-systemd-units of nosh makes
the service bundle in /etc/service-bundles/services when the service is enabled or started and when
daemon-reload finds the unit changed. enable, disable, start, stop and status are those of
system-control; enable reads the links back, because system-control enable exits 0 when it could not
make one. The marker is a comment in the run script of the bundle, and a bundle whose record is gone is
removed at the next daemon-reload of a running service manager. Verified with nosh 1.41 (the binary
packages of its author, checked by sha256) in a rootless container, with the service manager started
by local-datagram-socket-listen and not under system-manager; the control groups that the converted
run scripts move into do not exist for a rootless container, so the test mounts a tmpfs there.
- The converter reads the unit file and the drop-ins beside it, not the merge of every search
directory, and refuses what nosh cannot run:
Type=notify,Type=idle, and a stop mechanism it has no name for. It ignoresExecStop=,ExecReload=and the sandboxing settings, and mapsRestart=to arestartscript.reloadrunsExecReload=through the executor. Type=forkingis handled by the converter itself: nosh does not follow the daemon or readPIDFile=, sostartdoes not wait for it andstopdoes not end the forked daemon.- Services log where nosh sends them, not to the uniform location, so
journalctl -ushows nothing for them.restartis a stop and a start. User services are not supported, and in a--roottree the converter cannot run: the record is written andenablesays to reload on the target.
INI files, read in this order, later ones overriding earlier ones: /etc/fake-systemd/fake-systemd.conf,
/etc/fake-systemd/fake-systemd.conf.d/*.conf, and (user scope) $XDG_CONFIG_HOME/fake-systemd/fake-systemd.conf.
# Init: backend, "auto" detects the running init. Profile: distribution profile.
# Translate: lazy or eager.
[Main]
Init=auto
Profile=auto
Translate=lazy
# Scheduler: auto, native or builtin.
[Timers]
Scheduler=auto
# Maps a systemd unit to a native service of a different name, as in
# apache2.service=httpd. An alias is authoritative: when the native service exists it is
# used without comparing executables, and nothing is generated. When it does not exist,
# the normal name and executable rules apply. An empty value removes the alias.
[Aliases]
foo.service=bar
# Space-separated glob patterns that force or exclude translation.
[Classify]
Allow=
Deny=The environment overrides the files: FAKE_SYSTEMD_INIT, FAKE_SYSTEMD_PROFILE,
FAKE_SYSTEMD_DRY_RUN, FAKE_SYSTEMD_LOG_LEVEL.
Unit files are trusted as the packages that install them are: a unit is installed by root, and fake-systemd runs its commands, and hands its directories to its account, with the privileges of the caller. The executor limits what a service account can steer.
User=,Group=andSupplementaryGroups=names that start with-are refused. A name that is not in/etc/passwdand/etc/groupis refused as root (status 217 or 216) instead of running the service as root; accounts that only the system libc knows (LDAP, sssd) reach the executor as numeric ids, which always come as a uid and a gid together.RuntimeDirectory=,StateDirectory=,CacheDirectory=,LogsDirectory=andConfigurationDirectory=may not namefake-systemdor anything below it under any base: the index, its locks, the runtime state and the logs belong to root.- Like systemd, the directory settings take over an existing directory:
StateDirectory=dpkgchanges the owner of/var/lib/dpkgand everything in it to the service account. Symlinks are changed themselves, never followed; files with several links are skipped, since another link may lie outside the directory. Only install units whose directory names you would accept in systemd. Setting up a directory is refused when a component below the base is on another mount than the base; the ownership change skips a directory on another device, and the removal of a runtime directory refuses it. stop,reloadand kill act on the process that the executor recorded when it started the service, as<pid> <start time>in its root-owned state file, and only while that start time still holds.PIDFile=is read once, at start, and only for a process that descends from the executor; a pid file that names any other process, andMAINPIDfrom the caller, are ignored unless the process runs as the service account.- Backends read pid files through the opened file, without following links.
daemon-reloadstops nothing: a service whose unit file disappeared is disabled at boot and keeps running, except on inits (runit, s6) that stop a service when its definition is removed.
The toolchain is Zig, pinned in .zig-version and built into a container image by the Containerfile
(the Zig tarball is verified with the official minisign key):
packaging/build-toolchain.sh
podman run --rm -v "$PWD":/src:Z -w /src fake-systemd-build zig build -Doptimize=ReleaseSmall
podman run --rm -v "$PWD":/src:Z -w /src fake-systemd-build zig build -Dtarget=aarch64-linux-musl -Doptimize=ReleaseSmallThe result is in zig-out/bin. packaging/build-tarball.sh TARGET OUTDIR builds a release tarball.
podman run --rm -v "$PWD":/src:Z -w /src fake-systemd-build zig fmt --check build.zig src tests
podman run --rm -v "$PWD":/src:Z -w /src fake-systemd-build zig build test # unit, golden and integration tests
tests/e2e/dinit/run.sh # real dinit in a container
tests/e2e/runit/run.sh # real runsvdir in a Void container
tests/e2e/s6/run.sh # real s6-svscan and s6-rc in Artix and Alpine containers
tests/e2e/openrc/run.sh # real OpenRC in Alpine and Devuan containers
tests/e2e/sysvinit/run.sh # real sysvinit as PID 1 in Devuan and Debian, chkconfig in Rocky containers
tests/e2e/66/run.sh # real 66 as PID 1 (66 boot -c) in an Alpine container
tests/e2e/busybox/run.sh # real BusyBox init, runsvdir and sv as PID 1 in an Alpine container
tests/e2e/bsdrc/run.sh # real sysvinit with the boot scripts of Slackware as PID 1 in a container
tests/e2e/procd/run.sh # real procd as PID 1 in an OpenWrt root file system container
tests/e2e/finit/run.sh # real finit as PID 1 in a Debian container
tests/e2e/shepherd/run.sh # real shepherd daemon in a Debian container
tests/e2e/nosh/run.sh # real nosh converter and service manager in a Debian container
packaging/aur/test.sh # AUR package: makepkg and namcapGPL-3.0-or-later, see LICENSE. src/timers/calendar.zig and src/timers/schedule.zig are derived
from calendarspec.c and timer.c of systemd (LGPL-2.1-or-later) and keep that attribution in their
headers.