Get environment variable of other user

Another option is to use env. Run this as root :

sudo -Hiu $user env | grep $var

For example

sudo -Hiu terdon env | grep HOME
HOME=/home/terdon

For one user, you can do like this:

su - <username> -c '. ~/.profile; echo $PATH'

List $PATH of all user:

for user in $(cat /etc/passwd | awk -F: '{print $1}'); do
  su - $user -c '. ~/.profile; printf "%s\n" "$PATH"'
done

@Camil Staps

. ~/.profile is thus a trick I learn from my favourite person, Peteris Krumins. He explained the trick here . Maybe later bash version had building with option NON_INTERACTIVE_LOGIN_SHELLS.