Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I start a bash terminal, my .profile is not being executed. I do not have a ~/.bash_profile or a ~/.bash_login, so .profile is supposed to run, right? What else could be wrong?

share|improve this question
up vote 10 down vote accepted

It's not a login shell.

If a shell is a login shell, it will look for .bash_profile if it exists, then .profile. Other shells look for .bashrc

So, you can put the things you want in every shell instance in .bashrc, and possibly have a reference that sources .bashrc in .profile.

So: .bashrc:

stuff you want

end of .profile:

[ -n "$BASH" ] && [ -f ~/.bashrc ] && . ~/.bashrc
share|improve this answer
So when I run 'konsole' in KDE, that is a non-login shell, right? On another machine I have definitely put things in .profile and had them work when I open a terminal like this - I guess I don't understand when you'd want something different to happen at login vs when you open a terminal? – David Doria Feb 3 '12 at 22:53
@DavidDoria it depends, I have changed configs or made aliases to what konsole runs, to make it run bash --login. In your case it seems to just run bash, which by default will not trigger a login shell – Rich Homolka Feb 3 '12 at 22:56
If you are using LightDM that might be the reason. Other display managers like GDM and KDM source .profile on login, but LightDM does not (by design). See – WakiMiko Feb 3 '12 at 23:30
I am using KDM. – David Doria Feb 4 '12 at 2:25
If you are using Gnome Terminal, you can do Edit->Profile Preferences, go to the Title and Command tab, and check "Run command as a login shell". It will then source your .bash_profile or .profile whenever you open a terminal, as expected. – Lambart Sep 12 '13 at 3:00

try using ~/.bashrc instead.

share|improve this answer

If you're using a graphical desktop, .profile should be sourced by your desktop manager. Lightdm does source .profile now, at least on Ubuntu. See:

With kdm, and Kubuntu-12.04, the file /etc/kde4/kdm/Xsession gets sourced, which does the .profile including. Kubuntu-12.10 will probably use lightdm. Ubuntu 12.04 uses lightdm so that /usr/sbin/lightdm-session sources .profile.

I think the way to go is to (1) set/export environment settings in ~/.profile and (2) have .profile sourced by .bash_profile:

[[ -f ~/.profile ]] && . ~/.profile

(and not have .bashrc sourced by either .profile or .bash_profile).

See also:

share|improve this answer
This explains how to get your .profile sourced at login, but he's actually wondering about how to get bash to source it when he launches a terminal (not at login) – cpast Feb 4 '13 at 1:07
You shouldn't want to have .profile sourced when you launch a new terminal (from within KDE). The whole purpose of .profile is to have it sourced once at login, either on a graphical terminal or a text terminal; .profile should've been sourced the moment you logged into KDE. – Freddy Vulto Feb 4 '13 at 11:32
.profile should be sourced by your desktop manager. Well this depends on understanding of the file's purpose. In Debian, /etc/profile (and ~/.profile as its extension) is meant to be for bash-like shells. – Alois Mahdal Oct 27 '14 at 8:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.