I'm using Linux Mint. My login shell (cat /etc/passwd | grep myUserName) is bash.After I start my graphical desktop environment and run terminal emulator from it, I could see that .bash_profile is not sourced (environment vars that export in it is unset). But if I login from text console (ctrl+alt+F1) or manually run bash -l from terminal emulator, .bash_profile works fine.Am I wrong when I think that .bash_profile should source when X starts and all export'ed vars should be available in terminal, running from X?P.S. Placing all in .bashrc and sourcing it from .bash_profile is not good idea (https://stackoverflow.com/questions/902946/): environment stuff should be sourced only once.
Why doesn't my ~/.bash_profile work?
bash;shell;login;profile
The file ~/.bash_profile is read by bash when it is a login shell. That's what you get when you log in in text mode.When you log in under X, the startup scripts are executed by /bin/sh. On Ubuntu and Mint, /bin/sh is dash, not bash. Dash and bash both have the same core features, but dash sticks to these core features in order to be fast and small whereas bash adds a lot of features at the cost of requiring more resources. It is common to use dash for scripts that don't need the extra features and bash for interactive use (though zsh has a lot of nicer features).Most combinations of display manager (the program where you type your user name and password) and desktop environment read ~/.profile from the login scripts in /etc/X11/Xsession, /usr/bin/lightdm-session, /etc/gdm/Xsession or whichever is applicable. So put your environment variable definitions in ~/.profile. Make sure to use only syntax that dash supports.So what should you put where?A good .bash_profile loads .profile, and loads .bashrc if the shell is interactive.. ~/.profileif [[ $- == *i* ]]; then . ~/.bashrc; fiIn .profile, put environment variable definitions, and other session settings such as ulimit.In .bashrc, put bash interactive settings such as aliases, functions, completion, key bindings (that aren't in .inputrc), See also Difference between Login Shell and Non-Login Shell? and Alternative to .bashrc.