Where should you set environment variables persistently?
IntermediateConceptPackages, Shell & Text Tools
Answer
- Per user, interactive:
~/.bashrcor~/.profile. - System-wide for login shells: a script in
/etc/profile.d/*.sh. - System-wide simple
KEY=value:/etc/environment(read bypam_env, no shell expansion). - For a service:
Environment=orEnvironmentFile=in the systemd unit. Services do not read.bashrcor/etc/profile.
More on Packages, Shell & Text Tools
Compare apt and dnf package management.BeginnerWhat is the difference between `apt upgrade` and `apt full-upgrade`?IntermediateHow do you find which package provides a file or command?BeginnerHow do you pin or hold a package version?IntermediateHow are repositories and their GPG keys configured?AdvancedWhat is the difference between a login shell and an interactive non-login shell?Intermediate