environment.d - Linux


Overview

environment.d is a directory that stores files containing environment variable assignments for user sessions on Linux systems. It allows system administrators to manage and customize system-wide environment variables that are set for all users at login.

Syntax

environment.d/

Options/Flags

None

Examples

Setting a new environment variable

Create a file with the extension .conf under the environment.d directory, e.g.:

/etc/environment.d/custom_var.conf

Add the following line to the file:

CUSTOM_VAR=value

Appending to an existing environment variable

Add the following line to the existing file:

PATH=${PATH}:/new/directory

Common Issues

File not found

Ensure the file is present under the environment.d directory and has the correct extension .conf.

Permissions

Check if the file has appropriate permissions (644 or 755) for the system to read and execute it.

Integration

environment.d can be integrated with other commands, such as:

  • env: Displays the current environment variables.
  • set -a: Executes commands in the modified environment.

Related Commands

  • profile: Loads user-specific environment variables at login.
  • bashrc: Loads user-specific environment variables for interactive shells.
  • /etc/environment: Sets system-wide environment variables for all users.