Knowledge Base:Configuring environment variables

From Gentoo Wiki
Jump to:navigation Jump to:search


This document provides methods to initialize environment variables and run shell code at login.


This information applies to users of emerge, bash, X, GNOME, and Plasma.


Different shells, window servers, and compositors have different startup script locations.


To add environment variables to a startup script, open it with a text editor and add a key-value pair for each environment variable. bash shell code is also allowed. For example, adding the following sets MAKEOPTS variable to --jobs 12 when emerge starts:

FILE /etc/portage/make.conf
MAKEOPTS="--jobs 12"

The following sections cover the startup script locations for different pieces of software.

Files in /etc/env.d/ (see the Handbook).
Emerge (per-package)
Files in /etc/portage/env/.
X window managers and desktop environments
GNOME on X and Wayland
Plasma on X and Wayland (pre-startup)
Files in $HOME/.config/plasma-workspace/env/ with the .sh file extension (for example, /home/larry/.config/plasma-workspace/env/
Plasma 5 on X and Wayland (login)
System settings → Startup and Shutdown → Autostart → Add... → Add application... (this file must have a shebang).

External resources