$linuxjunkies
>

environment.d

also: environment.d directory, systemd environment.d

A directory where systemd reads drop-in configuration files to set environment variables for services and user sessions. Files in environment.d/ are processed in lexicographic order and allow modular configuration of system-wide or user environment settings.

environment.d is a configuration directory used by systemd to manage environment variables across the system or for individual user sessions. Instead of editing a single monolithic configuration file, administrators can place individual .conf files in this directory, making it easier to manage settings from different packages or roles.

The directory structure depends on scope: /etc/environment.d/ for system-wide settings, ~/.config/environment.d/ for user-specific settings, and /usr/lib/environment.d/ for vendor defaults. Files are processed alphabetically, so naming matters for precedence.

Each .conf file contains simple KEY=value pairs, one per line. For example, a file /etc/environment.d/99-custom.conf might contain PATH=/usr/local/bin:$PATH or LANG=en_US.UTF-8. These variables are then available to systemd services and user shells.

Related terms