Knowledge Base:Configuring environment variables
From Gentoo Wiki
Synopsis
This document provides methods to initialize environment variables and run shell code at login.
Environment
This information applies to users of emerge, bash, X, GNOME, and Plasma.
Analysis
Different shells, window servers, and compositors have different startup script locations.
Resolution
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.
- Global
- Files in /etc/env.d/ (see the Handbook).
- Emerge
- /etc/portage/make.conf.
- Emerge (per-package)
- Files in /etc/portage/env/.
- bash
- $HOME/.bashrc.
- X window managers and desktop environments
- $HOME/.xinitrc.
- GNOME on X and Wayland
- $HOME/.pam_environment.
- 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/path.sh.
- Plasma 5 on X and Wayland (login)
- System settings → Startup and Shutdown → Autostart → Add... → Add application... (this file must have a shebang).