What is the difference between /etc/environment and /etc/profile?
/etc/environment
is not part of POSIX, it belongs to PAM (Pluggable Authentication Module), and only programs compiled with PAM support are able to use it (primarily login systems, which subsequently start the shell or user environment). This means it isn't even read by your shell.
You can see the programs using /etc/environment
with grep -l pam_env /etc/pam.d/*
.
So /etc/environment
is used for setting variables for programs which are usually not started from a shell.
Extract from The Ubuntu help
/etc/environment
- This file is specifically meant for system-wide environment variable settings. It is not a script file, but rather consists of assignment expressions, one per line. Specifically, this file stores the system-wide locale and path settings.
/etc/profile
- This file gets executed whenever a bash login shell is entered (e.g. when logging in from the console or over ssh), as well as by the DisplayManager when the desktop session loads.
I think all this is just a convention but not far from a standard (I don't know about RedHat like systems ).