SYSTEMD(1)
๐ NAME ๐
systemd, init โ the systemd system and service manager ๐ซถ
๐ธ SYNOPSIS ๐ธ
/usr/lib/systemd/systemd [OPTIONS...]
init [OPTIONS...]
โจ DESCRIPTION โจ
Okay bestie, sit down, hydrate, because systemd is the system and service manager for Linux operating systems, and it is genuinely the moment. When it runs as the very first process on boot (as PID 1 ๐คฉ), it acts as the init system that brings up and maintains all your userspace services. And like, it doesn't just do that for the system โ separate instances get started for logged-in users so their services can start too. Everybody gets a systemd. Iconic behavior.
systemd is usually not invoked directly by the user, nope, it's installed as the /sbin/init symlink and started during early boot, like a queen arriving before everyone else. The user manager instances get started automatically through the user@.service(5) service, no manual labor required ๐
When it's running as a system instance, systemd interprets the configuration file system.conf and the files in the system.conf.d directories. When it's running as a user instance, systemd interprets the configuration file user.conf and the files in the user.conf.d directories. Wanna know more? See systemd-system.conf(5), it's giving documentation. ๐
systemd also contains native implementations of all the little tasks that have to happen during boot. For example, it sets the hostname, it configures the loopback network device... it literally does everything. It also sets up and mounts various API file systems, such as /sys/, /proc/, and /dev/. Chef's kiss ๐๐
Oh and heads up โ systemd will also reset the system clock during early boot if it appears to be set incorrectly. See the "System clock epoch" section below for that one. โฐ
Note that some but not all interfaces provided by systemd are covered by the Interface Portability and Stability Promise[1]. So like, check before you rely on it, bestie.
The D-Bus API of systemd is described in org.freedesktop.systemd1(5) and org.freedesktop.LogControl1(5) ๐
And if you're running systemd in a container or initrd environment? Then you should implement the Container Interface[2] or initrd Interface[3] specifications, respectively. Different vibe, different spec, iykyk.
๐ฆ UNITS ๐ฆ
systemd provides a whole dependency system between various entities called "units", and there are 11 different types of them. Units encapsulate all sorts of objects that are relevant for system boot-up and maintenance. The majority of units are configured in unit configuration files โ the syntax and basic set of options for those is described in systemd.unit(5) โ but some are created automatically from other configuration files, dynamically from system state, or programmatically at runtime. Very versatile, very demure ๐
Units may be in a number of states, described in the following table. And psst โ the various unit types may have a number of additional substates, which get mapped to the generalized unit states described here. Don't @ me.
Table 1. Unit ACTIVE states
activeโ Started, bound, plugged in, ..., depending on the unit type. โจinactiveโ Stopped, unbound, unplugged, ..., depending on the unit type.failedโ Similar toinactive, but the unit failed in some way (process returned error code on exit, crashed, an operation timed out, or after too many restarts). ๐activatingโ Changing from inactive to active. ๐deactivatingโ Changing from active to inactive. ๐maintenanceโ Unit is inactive and a maintenance operation is in progress. ๐งreloadingโ Unit is active and it is reloading its configuration. ๐refreshingโ Unit is active and a new mount is being activated in its namespace. ๐ฑ
๐ The unit types, ranked (not really, they're all valid)
The following unit types are available:
- Service units, which start and control daemons and the processes they consist of. For details, see
systemd.service(5). - Socket units, which encapsulate local IPC or network sockets in the system โ super useful for socket-based activation. For details about socket units, see
systemd.socket(5); for details on socket-based activation and other forms of activation, seedaemon(7). - Target units are useful to group units, or to provide well-known synchronization points during boot-up. See
systemd.target(5). - Device units expose kernel devices in systemd and may be used to implement device-based activation. For details, see
systemd.device(5). - Mount units control mount points in the file system. For details see
systemd.mount(5). - Automount units provide automount capabilities, for on-demand mounting of file systems as well as parallelized boot-up. See
systemd.automount(5). - Timer units are useful for triggering activation of other units based on timers. You may find details in
systemd.timer(5). - Swap units are very similar to mount units and encapsulate memory swap partitions or files of the operating system. They are described in
systemd.swap(5). - Path units may be used to activate other services when file system objects change or are modified. See
systemd.path(5). - Slice units may be used to group units which manage system processes (such as service and scope units) in a hierarchical tree for resource management purposes. See
systemd.slice(5). - Scope units are similar to service units, but they manage foreign processes instead of starting them as well. See
systemd.scope(5).
Units are named as their configuration files. Some units have special semantics โ the detailed list is available in systemd.special(7) ๐
๐ Dependencies, jobs, and the whole situation
systemd knows various kinds of dependencies, including positive and negative requirement dependencies (i.e. Requires= and Conflicts=) as well as ordering dependencies (After= and Before=).
NB: ordering and requirement dependencies are orthogonal. If only a requirement dependency exists between two units (e.g.foo.servicerequiresbar.service), but no ordering dependency (e.g.foo.serviceafterbar.service), and both are requested to start, they will be started in parallel. ๐โ๏ธ๐โ๏ธ It is a common pattern that both requirement and ordering dependencies are placed between two units. Also note that the majority of dependencies are implicitly created and maintained by systemd โ in most cases it should be unnecessary to declare additional dependencies manually, however it is possible to do this.
Application programs and units (via dependencies) may request state changes of units. In systemd, these requests are encapsulated as 'jobs' and maintained in a job queue. Jobs may succeed or can fail, and their execution is ordered based on the ordering dependencies of the units they have been scheduled for. It's giving task manager, but make it systemd.
On boot, systemd activates the target unit default.target, whose job is to activate on-boot services and other on-boot units by pulling them in via dependencies. Usually, the unit name is just an alias (symlink) for either:
graphical.targetโ for fully-featured boots into the UI ๐ฅ๏ธmulti-user.targetโ for limited console-only boots, for use in embedded or server environments, or similar; it's a subset ofgraphical.target๐ค
However! It is at the discretion of the administrator to configure it as an alias to any other target unit. Your system, your rules. See systemd.special(7) for details about these target units.
On first boot, systemd will enable or disable units according to preset policy. See systemd.preset(5) and "First Boot Semantics" in machine-id(5).
๐ง Memory management (systemd is NOT a hoarder)
systemd only keeps a minimal set of units loaded into memory. Specifically, the only units that are kept loaded into memory are those for which at least one of the following conditions is true:
- It is in an
active,activating,deactivatingorfailedstate (i.e. in any unit state except for"inactive") - It has a job queued for it
- It is a dependency of at least one other unit that is loaded into memory
- It has some form of resource still allocated (e.g. a service unit that is inactive but for which a process is still lingering that ignored the request to be terminated) ๐ค
- It has been pinned into memory programmatically by a D-Bus call
systemd will automatically and implicitly load units from disk โ if they are not loaded yet โ as soon as operations are requested for them. So like, in many respects, the fact of whether a unit is loaded or not is genuinely invisible to clients. Use systemctl list-units --all to comprehensively list all units currently loaded. Any unit for which none of the conditions above applies is promptly unloaded. Bye bestie ๐
Note that when a unit is unloaded from memory its accounting data is flushed out too. However, this data is generally not lost, because a journal log record is generated declaring the consumed resources whenever a unit shuts down. So it's fine. It's fine. ๐ซถ
๐ Cgroups, the group chat nobody asked for but everyone needed
Processes systemd spawns are placed in individual Linux control groups named after the unit which they belong to, in the private systemd hierarchy. (See Control Groups v2[4] for more information about control groups, or short "cgroups" โ yes, everyone calls them cgroups, that's just the vibe.)
systemd uses this to effectively keep track of processes. Control group information is maintained in the kernel, and is accessible via the file system hierarchy (beneath /sys/fs/cgroup/), or in tools such as systemd-cgls(1) or ps(1). And pro tip from the original, verbatim: ps xawf -eo pid,user,cgroup,args is particularly useful to list all processes and the systemd units they belong to. ๐โจ
Oh and btw bestie โ systemd is also compatible with a bunch of classic Unix stuff you already know and love, like /etc/fstab and the utmp database. It plays nice. ๐
๐ the transaction thing (aka systemd's lil queuing system)
systemd has what's called a minimal transaction system, and it's genuinely so smart of it. Here's the tea: whenever a unit is asked to start up or shut down, systemd adds that unit and all its dependencies into a temporary transaction. โจ
Then it does a vibe check ๐ต๏ธโ๏ธ on that transaction to see if it's consistent โ meaning, does the ordering of all the units come out cycle-free? If it's not consistent, systemd tries to fix it up, and it drops the non-essential jobs that might be the ones creating the loop. It also tries to suppress non-essential jobs that would stop a running service (rude behavior, honestly). Finally, it checks whether the jobs in the transaction contradict jobs that are already queued, and if they do, it'll optionally just abort the whole transaction then and there.
If everything works out and the transaction is consistent and minimized in its impact, it gets merged with all the already-outstanding jobs and added to the run queue. So effectively: before systemd executes any requested operation, it verifies that the operation actually makes sense, fixes it if it can, and only fails if it really, truly cannot work. Protective king. ๐
โ ๏ธ Important note, don't skip this: transactions are generated independently of a unit's state at runtime. So for example, if a start job is requested on an already started unit, it will still generate a transaction and wake up any inactive dependencies (and cause propagation of other jobs as per the defined relationships). Why? Because the enqueued job gets compared to the target unit's state at the time of execution, and it's marked successful and complete when both satisfy. However, that job also pulls in other dependencies due to the defined relationships, and thus leads to โ in our example โ start jobs for any of those inactive units getting queued as well. Chain reaction, but make it intentional. ๐
Units may also be generated dynamically at boot time and at system manager reload time โ for example based on other configuration files, or based on parameters passed on the kernel command line. For the nitty gritty on that, go see systemd.generator(7). ๐ฆ
๐ DIRECTORIES
System unit directories
The systemd system manager reads unit configuration from a whole bunch of different directories. So if a package wants to install unit files, it shall place them in the directory that gets returned by this:
pkg-config systemd --variable=systemdsystemunitdir
Other directories that get checked are /usr/local/lib/systemd/system and /usr/lib/systemd/system. ๐๏ธ
User configuration ALWAYS takes precedence. Periodt. And this next one gives you the path of the system configuration directory:
pkg-config systemd --variable=systemdsystemconfdir
Packages should only ever mess with the content of these directories using the enable and disable commands of the systemctl(1) tool โ don't be out here editing by hand, bestie, it's not the move. ๐ The full list of directories is provided over in systemd.unit(5).
User unit directories
Similar rules apply for the user unit directories. However, here the XDG Base Directory specification[5] is what's followed to find units. โจ
Applications should place their unit files in the directory returned by:
pkg-config systemd --variable=systemduserunitdir
And global configuration gets done in the directory reported by:
pkg-config systemd --variable=systemduserconfdir
The enable and disable commands of the systemctl(1) tool can handle both global (i.e. for all users) and private (for one user) enabling/disabling of units. Versatile. ๐ซถ And again โ full list of directories lives in systemd.unit(5).
๐จ SIGNALS
The service listens to a whole stack of UNIX process signals that can be used to request various actions asynchronously. Obsessed with an async queen. ๐
Signal handling is enabled very early during boot, before any further processes are invoked. However โ and this part matters โ a supervising container manager or similar that wants to request these operations via this mechanism has to take into consideration that this functionality is not available during the earliest initialization phase. So don't come for it too early, it won't answer. ๐ญ
An sd_notify() notification message carrying the X_SYSTEMD_SIGNALS_LEVEL=2 field gets emitted once the signal handlers are enabled, see below. You can use that to schedule submission of these signals correctly. Timing is everything, iykyk. โฐ
SIGTERMโ On receiving this signal, the systemd system manager serializes its state, reexecutes itself, and then deserializes the saved state again. This is mostly equivalent tosystemctl daemon-reexec. systemd user managers will start theexit.targetunit when this signal is received. That's mostly equivalent tosystemctl --user start exit.target --job-mode=replace-irreversibly.SIGINTโ On receiving this signal, the systemd system manager will start thectrl-alt-del.targetunit. Mostly equivalent tosystemctl start ctrl-alt-del.target --job-mode=replace-irreversibly. If this signal is received more than 7 times per 2s, an immediate reboot gets triggered. ๐ฅ Note that pressing Ctrl+Alt+Del on the console triggers this signal. Hence โ if a reboot is hanging, pressing Ctrl+Alt+Del more than 7 times in 2 seconds is a relatively safe way to trigger an immediate reboot. (Relatively. It said relatively.) systemd user managers treat this signal the same way asSIGTERM.SIGWINCHโ When this signal is received, the systemd system manager will start thekbrequest.targetunit. Mostly equivalent tosystemctl start kbrequest.target. This signal is ignored by systemd user managers.SIGPWRโ When this signal is received, the systemd manager will start thesigpwr.targetunit. Mostly equivalent tosystemctl start sigpwr.target.SIGUSR1โ When this signal is received, the systemd manager will try to reconnect to the D-Bus bus. ๐SIGUSR2โ When this signal is received, the systemd manager will log its complete state in human-readable form. The data logged is the same as what's printed bysystemd-analyze dump.SIGHUPโ Reloads the complete daemon configuration. Mostly equivalent tosystemctl daemon-reload.SIGRTMIN+0โ Enters default mode, starts thedefault.targetunit. Mostly equivalent tosystemctl isolate default.target.SIGRTMIN+1โ Enters rescue mode, starts therescue.targetunit. Mostly equivalent tosystemctl isolate rescue.target.SIGRTMIN+2โ Enters emergency mode, starts theemergency.serviceunit. Mostly equivalent tosystemctl isolate emergency.service.SIGRTMIN+3โ Halts the machine, starts thehalt.targetunit. Mostly equivalent tosystemctl start halt.target --job-mode=replace-irreversibly.SIGRTMIN+4โ Powers off the machine, starts thepoweroff.targetunit. Mostly equivalent tosystemctl start poweroff.target --job-mode=replace-irreversibly.SIGRTMIN+5โ Reboots the machine, starts thereboot.targetunit. Mostly equivalent tosystemctl start reboot.target --job-mode=replace-irreversibly.SIGRTMIN+6โ Reboots the machine via kexec, starts thekexec.targetunit. Mostly equivalent tosystemctl start kexec.target --job-mode=replace-irreversibly.SIGRTMIN+7โ Reboots userspace, starts thesoft-reboot.targetunit. Mostly equivalent tosystemctl start soft-reboot.target --job-mode=replace-irreversibly. Added in version 254.SIGRTMIN+13โ Immediately halts the machine. ๐SIGRTMIN+14โ Immediately powers off the machine.SIGRTMIN+15โ Immediately reboots the machine.SIGRTMIN+16โ Immediately reboots the machine with kexec.SIGRTMIN+17โ Immediately reboots the userspace. Added in version 254.SIGRTMIN+20โ Enables display of status messages on the console, as controlled viasystemd.show_status=1on the kernel command line. You may want to useSetShowStatus()instead ofSIGRTMIN+20in order to prevent race conditions. Seeorg.freedesktop.systemd1(5).SIGRTMIN+21โ Disables display of status messages on the console, as controlled viasystemd.show_status=0on the kernel command line. You may want to useSetShowStatus()instead ofSIGRTMIN+21in order to prevent race conditions. Seeorg.freedesktop.systemd1(5).SIGRTMIN+22โ Sets the service manager's log level to"debug", in a fashion equivalent tosystemd.log_level=debugon the kernel command line. ๐SIGRTMIN+23โ Restores the log level to its configured value. That configured value is derived from โ in order of priority โ the value specified withsystemd.log-level=on the kernel command line, or the value specified withLogLevel=in the configuration file, or the built-in default of"info". Added in version 239.SIGRTMIN+24โ Immediately exits the manager (only available for--userinstances). ๐ Added in version 195.SIGRTMIN+25โ On receiving this signal, the systemd manager will reexecute itself. Mostly equivalent tosystemctl daemon-reexec, except that it gets done asynchronously. The systemd system manager treats this signal the same way asSIGTERM. Added in version 250.SIGRTMIN+26โ Restores the log target to its configured value. The configured value is derived from โ in order of priority โ the value specified withsystemd.log-target=on the kernel command line, or the value specified withLogTarget=in the configuration file, or the built-in default. Added in version 239.SIGRTMIN+27,SIGRTMIN+28โ Sets the log target to"console"onSIGRTMIN+27(or"kmsg"onSIGRTMIN+28), in a fashion equivalent tosystemd.log_target=console(orsystemd.log_target=kmsgonSIGRTMIN+28) on the kernel command line. Added in version 239.
๐ ENVIRONMENT ๐
okay bestie so the environment block for the system manager? it does not start out cute and empty โ the kernel sets it up initially. and when you write key=value assignments on the kernel command line, those get turned into environment variables for PID 1, fr fr. ๐ซถ
for the user manager, the system manager hands it the environment as described in the "Environment Variables in Spawned Processes" section of systemd.exec(5). and listen โ the DefaultEnvironment= setting in the system manager applies to all services, including user@.service. that's iconic. โจ
you can also add extra entries (just like for any other service) through the Environment= and EnvironmentFile= settings on user@.service (go read systemd.exec(5)), and you can set additional environment variables through the ManagerEnvironment= setting in systemd-system.conf(5) and systemd-user.conf(5). so many doors, same house. ๐
here's a lil rundown of some of the variables systemd understands:
$SYSTEMD_LOG_LEVEL
the maximum log level of emitted messages โ meaning messages with a higher log level (i.e. the less important ones) get suppressed. it takes a comma-separated list of values. each value is either one of these, listed in order of decreasing importance: emerg, alert, crit, err, warning, notice, info, debug โ or just an integer in the range 0...7. see syslog(3) for more info.
each value may optionally be prefixed with one of console, syslog, kmsg or journal followed by a colon, which sets the maximum log level for that specific log target. like this, bestie:
SYSTEMD_LOG_LEVEL=debug,console:info
that says log at debug level, except when logging to the console, where it should be at info level. but note!! the global maximum log level takes priority over any per-target maximum log levels. periodt.
this can be overridden with --log-level=.
$SYSTEMD_LOG_COLOR
a boolean. if true, messages written to the tty get colored according to priority. ๐
this can be overridden with --log-color=.
$SYSTEMD_LOG_TIME
a boolean. if true, console log messages get prefixed with a timestamp. โฐ
this can be overridden with --log-time=.
Added in version 246.
$SYSTEMD_LOG_LOCATION
a boolean. if true, messages get prefixed with a filename and line number in the source code where the message originates. so you can see exactly where it came from, iykyk. ๐
this can be overridden with --log-location=.
$SYSTEMD_LOG_TID
a boolean. if true, messages get prefixed with the current numerical thread ID (TID).
Added in version 247.
$SYSTEMD_LOG_TARGET
where your log messages go, bestie. one of:
consoleโ log to the attached ttyconsole-prefixedโ log to the attached tty but with prefixes encoding the log level and "facility", seesyslog(3)kmsgโ log to the kernel circular log bufferjournalโ log to the journaljournal-or-kmsgโ log to the journal if available, and to kmsg otherwiseautoโ determine the appropriate log target automatically, this is the defaultnullโ disable log output entirely (silence era, honestly)
this can be overridden with --log-target=.
$SYSTEMD_LOG_RATELIMIT_KMSG
whether to ratelimit kmsg or not. takes a boolean. defaults to "true". if disabled, systemd will not ratelimit messages written to kmsg. no cap.
Added in version 254.
$XDG_CONFIG_HOME, $XDG_CONFIG_DIRS, $XDG_DATA_HOME, $XDG_DATA_DIRS
the systemd user manager uses these variables in accordance to the XDG Base Directory specification[5] to find its configuration. home is where the config is. ๐
$SYSTEMD_UNIT_PATH, $SYSTEMD_GENERATOR_PATH, $SYSTEMD_ENVIRONMENT_GENERATOR_PATH
these control where systemd looks for unit files and generators. they may contain a list of paths, separated by colons (":"). when set, if the list ends with an empty component ("...:"), the list is prepended to the usual set of paths. otherwise, the list you specified replaces the usual set of paths. so that trailing colon is doing a whole lot of work, lowkey. ๐
$SYSTEMD_PAGER, $PAGER
which pager to use when --no-pager isn't given. $SYSTEMD_PAGER is used if it's set; otherwise $PAGER gets the job. if neither $SYSTEMD_PAGER nor $PAGER are set, a set of well-known pager implementations is tried in turn โ including less(1) and more(1) โ until one is found. if no pager implementation is discovered at all, no pager gets invoked. setting either of these environment variables to an empty string or to the value "cat" is equivalent to passing --no-pager.
Note: if$SYSTEMD_PAGERSECUREis not set,$SYSTEMD_PAGERand$PAGERcan only be used to disable the pager (with"cat"or""), and are otherwise ignored. big deal, remember this one.
$SYSTEMD_LESS
override the options passed to less (by default "FRSXMK").
users might want to change two options in particular:
Kโ this option instructs the pager to exit immediately when Ctrl+C is pressed. to allowlessto handle Ctrl+C itself so it can switch back to the pager command prompt, you unset this option. if the value of$SYSTEMD_LESSdoes not include"K", and the pager that gets invoked isless, then Ctrl+C will be ignored by the executable, and needs to be handled by the pager.Xโ this option instructs the pager to not send termcap initialization and deinitialization strings to the terminal. it's set by default to allow command output to remain visible in the terminal even after the pager exits. nevertheless, this prevents some pager functionality from working โ in particular, paged output cannot be scrolled with the mouse. ๐ญ
note that setting the regular $LESS environment variable has no effect for less invocations made by systemd tools. see less(1) for more discussion.
$SYSTEMD_LESSCHARSET
override the charset passed to less (by default "utf-8", if the invoking terminal is determined to be UTF-8 compatible). ๐ธ
note that setting the regular $LESSCHARSET environment variable has no effect for less invocations by systemd tools. same energy as above.
$SYSTEMD_PAGERSECURE
okay this one is the important one, bestie, sit down. โ
common pager commands like less(1), in addition to just "paging" โ i.e. scrolling through the output โ support opening of or writing to other files and running arbitrary shell commands. when commands are invoked with elevated privileges, for example under sudo(8) or pkexec(1), the pager becomes a security boundary. care must be taken that only programs with strictly limited functionality are used as pagers, and that unintended interactive features โ like opening or creation of new files, or starting of subprocesses โ are not allowed. "Secure mode" for the pager may be enabled as described below, if the pager supports that (and ngl, most pagers are not written in a way that takes this into consideration ๐). it is recommended to either explicitly enable "secure mode" or to completely disable the pager using --no-pager or PAGER=cat when allowing untrusted users to execute commands with elevated privileges.
this option takes a boolean argument. when set to true, the "secure mode" of the pager is enabled. in "secure mode", LESSSECURE=1 will be set when invoking the pager, which instructs the pager to disable commands that open or create new files or start new subprocesses. currently only less(1) is known to understand this variable and implement "secure mode".
when set to false, no limitation is placed on the pager. setting SYSTEMD_PAGERSECURE=0 or not removing it from the inherited environment may allow the user to invoke arbitrary commands. โ ๏ธ
when $SYSTEMD_PAGERSECURE is not set, systemd tools attempt to automatically figure out if "secure mode" should be enabled and whether the pager supports it. "secure mode" is enabled if the effective UID is not the same as the owner of the login session โ see geteuid(2) and sd_pid_get_owner_uid(3) โ or when running under sudo(8) or similar tools ($SUDO_UID is set [6]). in those cases, SYSTEMD_PAGERSECURE=1 will be set and pagers which are not known to implement "secure mode" will not be used at all. note that this autodetection only covers the most common mechanisms to elevate privileges and is intended as convenience. it is recommended to explicitly set $SYSTEMD_PAGERSECURE or disable the pager.
note that if$SYSTEMD_PAGERor$PAGERvariables are to be honoured, other than to disable the pager,$SYSTEMD_PAGERSECUREmust be set too. ๐
$SYSTEMD_COLORS
takes a boolean argument. when true, systemd and related utilities use colors in their output; otherwise the output will be monochrome. additionally, this variable can take one of the following special values: "16", "256" โ to restrict the use of colors to the base 16 or 256 ANSI colors, respectively. this can be specified to override the automatic decision based on $TERM and what the console is connected to. ๐จ
$SYSTEMD_URLIFY
the value must be a boolean. this controls whether clickable links should be generated in the output, for terminal emulators that support it. this can be specified to override the decision systemd makes based on $TERM and other conditions. ๐
$LISTEN_PID, $LISTEN_PIDFDID, $LISTEN_FDS, $LISTEN_FDNAMES
set by systemd for supervised processes during socket-based activation. see sd_listen_fds(3) for more information. ๐งฆ
$NOTIFY_SOCKET
set by the service manager for its services, for status and readiness notifications. it's also consumed by the service manager for notifying supervising container managers or service managers further up the stack about its own progress. see sd_notify(3) and the relevant section below for more information. ๐ฃ
for further environment variables understood by systemd and its various components, see Known Environment Variables[7]. there's always more lore. ๐ฆ
๐ฆ KERNEL COMMAND LINE ๐ฆ
okay so when systemd runs as the system instance, it reads a whole lil list of options, right? and where it reads them from depends on the vibe of the environment it's living in. so here's the tea:
- if you're inside a Linux container, these options get parsed from the command line arguments passed to
systemditself โ right next to any of the command line options from the Options section up above ๐ - if you're outside</> of Linux containers, the arguments get parsed from
/proc/cmdlineinstead
the following variables are understood, bestie:
systemd.unit=,rd.systemd.unit=โ overrides which unit gets activated on boot. defaults todefault.target. you can use this to temporarily boot into a different boot unit, likerescue.targetoremergency.service. peepsystemd.special(7)for the deets on those units. the one prefixed withrd.is honored only in the initrd, while the non-prefixed one is honored only in the main system. โจsystemd.dump_coreโ takes a boolean argument, or just enables the option if you specify it with no argument at all. if enabled, the systemd manager (PID 1) dumps core when it crashes. otherwise? no core dump, no drama. defaults to enabled.
Added in version 233.
systemd.crash_chvtโ takes a positive integer, or a boolean argument. can also be specified with no argument, with the same effect as a positive boolean. if you give it a positive integer (in the range1โ63), the system manager (PID 1) will activate that specified virtual terminal when it crashes. defaults to disabled, meaning no such switch is attempted. if set to enabled, it uses the virtual terminal the kernel messages are written to instead.
Added in version 233.
systemd.crash_shellโ takes a boolean argument, or enables the option if specified with no argument. if enabled, the system manager (PID 1) spawns a shell when it crashes. otherwise, no shell. defaults to disabled, for security reasons, because that shell is not protected by password authentication. so like, be careful bestie ๐ญ
Added in version 233.
systemd.crash_action=โ takes one of"freeze","reboot"or"poweroff". defaults to"freeze". if set to"freeze", the system will hang indefinitely when the system manager (PID 1) crashes. if set to"reboot", the system manager (PID 1) will reboot the machine automatically when it crashes, after a10sdelay. if set to"poweroff", the system manager (PID 1) will power off the machine immediately when it crashes. and if you combine this withsystemd.crash_shell, the configured crash action is executed after the shell exits.
Added in version 256.
systemd.confirm_spawnโ takes a boolean argument, or a path to the virtual console where the confirmation messages should be emitted. can also be specified with no argument, with the same effect as a positive boolean. if enabled, the system manager (PID 1) asks for confirmation when spawning processes using/dev/console. if a path or a console name (like"ttyS0") is provided, the virtual console pointed to by that path or described by the given name is used instead. defaults to disabled.
Added in version 233.
systemd.service_watchdogs=โ takes a boolean argument. if disabled, all service runtime watchdogs (WatchdogSec=) and emergency actions (e.g.OnFailure=orStartLimitAction=) are ignored by the system manager (PID 1); seesystemd.service(5). defaults to enabled, i.e. watchdogs and failure actions are processed normally. the hardware watchdog is not affected by this option, jsyk.
Added in version 237.
systemd.show_statusโ takes a boolean argument or the constantserrorandauto. can also be specified with no argument, with the same effect as a positive boolean. if enabled, the systemd manager (PID 1) shows terse service status updates on the console during bootup. witherror, only messages about failures are shown, but boot is otherwise quiet.autobehaves like false until there's a significant delay in boot. defaults to enabled, unlessquietis passed as a kernel command line option โ in which case it defaults toerror. if specified, it overrides the system manager configuration file optionShowStatus=, seesystemd-system.conf(5).
Added in version 233.
systemd.status_unit_format=โ takesname,descriptionorcombinedas the value. ifname, the system manager will use unit names in status messages. ifcombined, the system manager will use unit names and description in status messages. when specified, overrides the system manager configuration file optionStatusUnitFormat=, seesystemd-system.conf(5).
Added in version 243.
systemd.log_color,systemd.log_level=,systemd.log_location,systemd.log_target=,systemd.log_time,systemd.log_tid,systemd.log_ratelimit_kmsgโ controls log output, with the exact same effect as the$SYSTEMD_LOG_COLOR,$SYSTEMD_LOG_LEVEL,$SYSTEMD_LOG_LOCATION,$SYSTEMD_LOG_TARGET,$SYSTEMD_LOG_TIME,$SYSTEMD_LOG_TIDand$SYSTEMD_LOG_RATELIMIT_KMSGenvironment variables described up above. note thatsystemd.log_color,systemd.log_location,systemd.log_time,systemd.log_tidandsystemd.log_ratelimit_kmsgcan be specified with no argument, with the same effect as a positive boolean. ๐systemd.default_standard_output=,systemd.default_standard_error=โ controls the default standard output and error output for services and sockets. like, it controls the default forStandardOutput=andStandardError=(seesystemd.exec(5)for the whole story). takes one ofinherit,null,tty,journal,journal+console,kmsg,kmsg+console. if the argument is omitted,systemd.default-standard-output=defaults tojournalandsystemd.default-standard-error=defaults toinherit. ๐systemd.setenv=โ takes a string argument in the formVARIABLE=VALUE. you can use this to set default environment variables that get added to forked child processes. you can use it more than once to set multiple variables, slay. โจsystemd.machine_id=โ takes a32character hex value to be used for setting the machine-id. intended mostly for network booting, where you want the same machine-id for every single boot.
Added in version 229.
systemd.set_credential=,systemd.set_credential_binary=โ sets a system credential, which can then be propagated to system services using theImportCredential=orLoadCredential=setting, seesystemd.exec(5)for details. takes a pair of credential name and value, separated by a colon. thesystemd.set_credential=parameter expects the credential value in literal text form, while thesystemd.set_credential_binary=parameter takes binary data encoded inBase64. okay so important: the kernel command line is typically accessible by unprivileged programs in/proc/cmdline. so bestie, this mechanism is not suitable for transferring sensitive data ๐ use it only for data that isn't sensitive (like public keys/certificates, rather than private keys), or in testing/debugging environments. periodt.
for further info, see the System and Service Credentials[8] documentation.
Added in version 251.
systemd.import_credentials=โ takes a boolean argument. if false, it disables importing credentials from the kernel command line, the DMI/SMBIOS OEM string table, theqemu_fw_cfgsubsystem or the EFI kernel stub.
Added in version 251.
quietโ turns off status output at boot, much likesystemd.show_status=nowould. note that this option is also read by the kernel itself and disables kernel log output. so passing this option turns off the usual output from both the system manager and the kernel. ๐คซ
Added in version 186.
debugโ turns on debugging output. this is equivalent tosystemd.log_level=debug. note that this option is also read by the kernel itself and enables kernel debug output. so passing this option turns on the debug output from both the system manager and the kernel. ๐ฅ
Added in version 205.
emergency,rd.emergencyโ boot into emergency mode. these options are equivalent tosystemd.unit=emergency.targetorrd.systemd.unit=emergency.target, respectively. they were initially provided for compatibility with SysV, but they're retained as convenient shortcuts. ๐
Added in version 186.
rescue,rd.rescue,single,1โ boot into rescue mode. these options are equivalent to eithersystemd.unit=rescue.targetorrd.systemd.unit=rescue.target. they were initially provided for compatibility with SysV, but they're retained as convenient shortcuts. ๐
Added in version 186.
3,5โ shortcuts to boot into specific targets:3is equivalent tosystemd.unit=multi-user.targetand5is equivalent tosystemd.unit=graphical.target. these were initially provided for compatibility with SysV, but they're retained as convenient shortcuts.
Added in version 186.
locale.LANG=,locale.LANGUAGE=,locale.LC_CTYPE=,locale.LC_NUMERIC=,locale.LC_TIME=,locale.LC_COLLATE=,locale.LC_MONETARY=,locale.LC_MESSAGES=,locale.LC_PAPER=,locale.LC_NAME=,locale.LC_ADDRESS=,locale.LC_TELEPHONE=,locale.LC_MEASUREMENT=,locale.LC_IDENTIFICATION=โ set the system locale to use. this overrides the settings in/etc/locale.conf. for more information, seelocale.conf(5)andlocale(7). ๐
Added in version 186.
and for any other kernel command line parameters understood by components of the core OS, please refer to kernel-command-line(7). ๐ซถ
๐ SYSTEM CREDENTIALS ๐
okay so during init the service manager is gonna import credentials from a bunch of different sources into the system's set of credentials, and then those can get propagated into services and eaten up by generators. here's the whole rundown bestie:
- When the service manager first initializes, it reads system credentials from SMBIOS Type 11 vendor strings
io.systemd.credential:name=value, andio.systemd.credential.binary:name=value. - At the same exact time it also imports credentials from QEMU
"fw_cfg". (quick note: the SMBIOS mechanism is generally preferred, because it's faster and generic. ๐ ) - Credentials may be passed via the kernel command line, using the
systemd.set-credential=parameter, see above. - Credentials may be passed from the UEFI environment via
systemd-stub(7). - When the service manager is invoked during the initrd โ host transition it will import all files in
/run/credentials/@initrd/as system credentials.
wanna see the list of credentials that got passed into your system? run systemd-creds(1) like this:
# systemd-creds --system list
for more deets see the System and Service Credentials[8] documentation. โจ
so when the service manager is running as PID 1, it consumes these system credentials right here:
vmm.notify_socketโ contains anAF_VSOCKorAF_UNIXaddress where to send aREADY=1notification message when the service manager has completed booting. Seesd_notify(3)and the next section for more info. heads up: if the hypervisor does not supportSOCK_DGRAMoverAF_VSOCK,SOCK_SEQPACKETwill be tried instead. the credential payload forAF_VSOCKshould be a string in the form"vsock:CID:PORT"."vsock-stream","vsock-dgram"and"vsock-seqpacket"can be used instead of"vsock"to force usage of the corresponding socket type.
This feature is useful for machine managers or other processes on the host to receive a notification via VSOCK when a virtual machine has finished booting. ๐ฆ
Added in version 254.
system.machine_idโ takes a 128bit hexadecimal ID to initialize/etc/machine-idfrom, if the file is not set up yet. Seemachine-id(5)for details. ๐
Added in version 254.
For a list of system credentials that various other components of systemd consume, see systemd.system-credentials(7). โจ
๐ฃ READINESS PROTOCOL ๐ฃ
ngl this one's kinda iconic. the service manager implements a readiness notification protocol both between the manager and its services (i.e. down the stack), and between the manager and a potential supervisor further up the stack (which could be a machine or container manager, or in case of a per-user service manager, the system service manager instance). the basic protocol (and the suggested API for it) is described in sd_notify(3). ๐ซถ
The notification socket the service manager (including PID 1) uses for reporting readiness to its own supervisor is set via the usual $NOTIFY_SOCKET environment variable (see above). Since this is directly settable only for container managers and for the per-user instance of the service manager, an additional mechanism to configure this is available, in particular intended for use in VM environments: the vmm.notify_socket system credential (see above) may be set to a suitable socket (typically an AF_VSOCK one) via SMBIOS Type 11 vendor strings. For details see above. ๐
okay so the notification protocol going from the service manager up the stack towards a supervisor supports a bunch of extension fields that let a supervisor learn about specific properties of the system and track its boot progress. specifically, these fields get sent:
- An
X_SYSTEMD_HOSTNAME=...message will be sent out once the initial hostname for the system has been determined. note that during later runtime the hostname might be changed again programmatically, and (currently) no further notifications are sent out in that case. ๐ญ
Added in version 256.
- An
X_SYSTEMD_MACHINE_ID=...message will be sent out once the machine ID of the system has been determined. Seemachine-id(5)for details.
Added in version 256.
- An
X_SYSTEMD_SIGNALS_LEVEL=...message will be sent out once the service manager installed the various UNIX process signal handlers described above. the field's value is an unsigned integer formatted as decimal string, and it indicates the supported UNIX process signal feature level of the service manager. currently, only a single feature level is defined:X_SYSTEMD_SIGNALS_LEVEL=2covers the various UNIX process signals documented above โ which are a superset of those supported by the historical SysV init system.
โ ๏ธ signals sent to PID 1 before this message is sent might not be handled correctly yet. A consumer of these messages should parse the value as an unsigned integer that indicates the level of support. For now only the mentioned level 2 is defined, but later on additional levels might be defined with higher integers, that will implement a superset of the currently defined behaviour. ๐
Added in version 256.
X_SYSTEMD_UNIT_ACTIVE=...andX_SYSTEMD_UNIT_INACTIVE=...messages will be sent out for each target unit as it becomes active or stops being active. this is useful to track boot progress and functionality. for example, once thessh-access.targetunit is reported started, SSH access is typically available, seesystemd.special(7)for details. โจ
Added in version 256.
- An
X_SYSTEMD_SHUTDOWN=...message will be sent out very shortly before the system shuts down. the value is one of the strings"reboot","halt","poweroff","kexec"and indicates which kind of shutdown is being executed. ๐
Added in version 256.
- An
X_SYSTEMD_REBOOT_PARAMETER=...message will also be sent out very shortly before the system shuts down. its value is the reboot argument as configured withsystemctl --reboot-argument=....
Added in version 256.
psst โ note that these extension fields are sent in addition to the regular"READY=1"and"RELOADING=1"notifications. ๐
โจ OPTIONS โจ
okay so real talk bestie: you will almost never run systemd by hand ๐
. it boots up mad early and it's already running by the time you, a whole human, could even type at it. when you wanna boss it around you use tools like systemctl(1), periodt. so because direct invocation is basically a special-occasion thing, all the options below are mostly for debugging and other special purposes ๐ฆ.
๐ Introspection and debugging options
these ones are for testing and peeking inside ๐ โ and systemd can be invoked with them at any time:
--dump-configuration-itemsโ dumps all the unit configuration items it understands ๐. it spits out a terse but complete list of every configuration item understood in unit definition files.--dump-bus-propertiesโ dumps the bus properties it exposes โจ. terse but complete list of every property exposed on D-Bus. Added in version 239.--testโ figures out the initial start-up transaction (aka the list of jobs enqueued at start-up), dumps it, and dips โ without actually executing any of the determined jobs. this is a debugging-only flex ngl. heads up though: during regular service manager start-up, extra units that this operation doesn't show may get started anyway, because hardware, socket, bus or other kinds of activation might add additional jobs as the transaction is executed ๐ญ. use--systemto ask for the initial transaction of the system service manager (this is also the implied default), or combine it with--userto ask for the initial transaction of the per-user service manager instead.--system,--userโ when you use these with--test, they pick whether you're calculating the initial transaction for the system instance or for a per-user instance ๐. without--testthey do literally nothing, because during regular (i.e. non---test) invocations the service manager just auto-detects whether it should run in system or per-user mode by checking whether the PID it's run as is1or not. note: booting and maintaining a system with the service manager running in--systemmode but with a PID other than1is not supported. don't do it ๐.-h,--helpโ prints a short help text and exits. the classic ๐.--versionโ prints a short version string and exits โญ.
๐งญ Options that duplicate kernel command line settings
these options map one-to-one onto the options listed above in "Kernel Command Line" ๐. for the system manager both forms work exactly the same, but the glow-up recommendation is to use the forms listed above in this context, because they're properly namespaced ๐ . and if an option shows up both on the kernel command line and as a normal command line argument, the latter wins โ higher precedence, no cap.
when systemd runs as a user manager, the kernel command line is completely ignored and only the options described below are understood ๐ฆ. still, systemd is usually started in this mode through the user@.service(5) service, which is shared between all users. it may be more convenient to use configuration files to tweak settings (see systemd-user.conf(5)), or environment variables ๐ธ. see the "Environment" section above for the whole discussion on how the environment block gets set.
--unit=โ set the default unit to activate on startup. if you don't specify it, it defaults todefault.target. seesystemd.unit=above ๐.--dump-coreโ enable core dumping on crash ๐. this switch has no effect when running as a user instance. same assystemd.dump_core=above.--crash-vt=VTโ switch to a specific virtual console (VT) on crash. no effect when running as a user instance. same assystemd.crash_chvt=above (but not the different spelling!). Added in version 227.--crash-shellโ run a shell on crash ๐. no effect when running as a user instance. seesystemd.crash_shell=above.--crash-action=โ specify what to do when the system manager (PID 1) crashes. no effect whensystemdis running as a user instance. seesystemd.crash_action=above. Added in version 256.--confirm-spawnโ ask for confirmation when spawning processes ๐. no effect when run as a user instance. seesystemd.confirm_spawnabove.--show-statusโ show terse unit status info on the console during boot-up and shutdown. seesystemd.show_statusabove. Added in version 244.--log-colorโ highlight important log messages ๐จ. seesystemd.log_colorabove. Added in version 244.--log-level=โ set the log level. seesystemd.log_levelabove.--log-locationโ include code location in log messages ๐. seesystemd.log_locationabove. Added in version 244.--log-target=โ set the log target. seesystemd.log_targetabove.--log-time=โ prefix console messages with a timestamp โฐ. seesystemd.log_timeabove. Added in version 246.--machine-id=โ override the machine-id set on the hard drive. seesystemd.machine_id=above. Added in version 229.--service-watchdogsโ globally enable/disable all service watchdog timeouts and emergency actions ๐. seesystemd.service_watchdogsabove. Added in version 237.--default-standard-output=,--default-standard-error=โ sets the default output or error output for all services and sockets, respectively. seesystemd.default_standard_output=andsystemd.default_standard_error=above.
โณ SYSTEM CLOCK EPOCH โณ
when systemd is started or restarted, it may set the system clock to the "epoch" โจ. this whole mechanism exists so the system clock stays somewhat reasonably initialized and roughly monotonic across reboots โ like, in case no battery-backed local RTC is available, or the one you've got doesn't work correctly ๐ญ. it's giving "we do our best with what we have."
the epoch is the lowest date above which the system clock time is assumed to be set correctly ๐. when initializing, the local clock gets advanced to the epoch if it was set to a lower value. and here's the special case: if the local clock is sufficiently far in the future โ by default 15 years, though this can be configured at build time โ the hardware clock is assumed to be broken ๐, and the system clock gets rewound to the epoch.
the epoch is set to the highest of these three things:
- the build time of
systemd - the modification time (
"mtime") of/usr/lib/clock-epoch - the modification time of
/var/lib/systemd/timesync/clock
๐ FILES ๐
/run/systemd/notifyโ daemon status notification socket ๐ซถ. this is anAF_UNIXdatagram socket and it's used to implement the daemon notification logic as implemented bysd_notify(3)./run/systemd/privateโ used internally as the communication channel betweensystemctl(1)and thesystemdprocess ๐. this is anAF_UNIXstream socket. this interface is private tosystemdand should not be used in external projects, fr fr./usr/lib/clock-epochโ the modification time ("mtime") of this file is used for the time epoch, see the previous section โณ. Added in version 247./var/lib/systemd/timesync/clockโ the modification time ("mtime") of this file is updated bysystemd-timesyncd.service(8)๐ฐ๏ธ. if present, the modification time of the file is used for the epoch, see the previous section. Added in version 257.
๐ HISTORY ๐
systemd 252 โ the kernel command-line arguments systemd.unified_cgroup_hierarchy and systemd.legacy_systemd_cgroup_controller were deprecated ๐ญ. please switch to the unified cgroup hierarchy. like, actually please. the old way is over, bestie ๐
.
๐ SEE ALSO ๐
the [systemd Homepage][9] ๐, systemd-system.conf(5), locale.conf(5), systemctl(1), journalctl(1), systemd-notify(1), daemon(7), sd-daemon(3), org.freedesktop.systemd1(5), systemd.unit(5), systemd.special(7), pkg-config(1), kernel-command-line(7), bootup(7), systemd.directives(7), org.freedesktop.systemd1(5) (yes it's listed twice, that's just how much we love it ๐ซถ).
for more info about the concepts and ideas behind systemd, please refer to the [Original Design Document][10] ๐.
๐ NOTES ๐
- Interface Portability and Stability Promise โ
https://systemd.io/PORTABILITY_AND_STABILITY/ - Container Interface โ
https://systemd.io/CONTAINER_INTERFACE - initrd Interface โ
https://systemd.io/INITRD_INTERFACE/ - Control Groups v2 โ
https://docs.kernel.org/admin-guide/cgroup-v2.html - XDG Base Directory specification โ
https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html - it is recommended for other tools to set and check
$SUDO_UIDas appropriate, treating it as a common interface ๐ซก. - Known Environment Variables โ
https://systemd.io/ENVIRONMENT - System and Service Credentials โ
https://systemd.io/CREDENTIALS - systemd Homepage โ
https://systemd.io/ - Original Design Document โ
https://0pointer.de/blog/projects/systemd.html
and that's a wrap on the whole SYSTEMD(1) saga, bestie ๐โจ this was systemd 259.10, i.e. the SYSTEMD(1) era of the manual page โ go forth and read the rest of the series, you absolute icon ๐๐
๐ฆ where this page comes from
- fedora 44: systemd 259.10-1.fc44 ยท LGPL-2.1-or-later AND MIT AND GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms