Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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

My .bash_profile is like below:

alias l='ls -l'
alias p='pwd'
alias sites='cd /home/caveman/sites'
alias time_card='cd /home/caveman/sites/time-card/time-card'
alias ping='ping'
alias bash_profile='gedit /home/caveman/.bash_profile'
alias webroot='cd /var/www'

every time I log into my machine I need to run the source .bash_profile to make all the alias available.

Can you guys figure out where is the problem is?

share|improve this question
Take a look here:… There is a good explanation. – user174388 Jul 11 '13 at 15:39
up vote 5 down vote accepted

The ~/.bash_profile is only read in login session.

Also, having a ~/.bash_profile prevents the sourcing of ~/.profile, that is the preferred file to use for login shell in the bash configuration for Ubuntu.

When you log in the Display Manager (I suppose GDM), the ~/.profile is read by default (I don't know if GDM follows bash rules and read ~/.bash_profile instead, if exists).

Even if ~/.bash_profile were read from GDM, aliases are not inherited, so the shell you have in a graphics terminal (that is not a login shell) cannot see them.

The solution is: put your aliases in ~/.bashrc, and use aliases only for very simple things, otherwise use functions.

The file ~/.bashrc is read by non-login interactive shells, and is sourced in ~/.profile, so that its content is also available in login shells.

share|improve this answer
I see,in MAC OSX the bash profile works for alias as why I tried same in ubuntu,thanks for your navigation :) – mushfiq Sep 23 '11 at 7:57

You could just add the aliases to ~/.bash_aliases instead

share|improve this answer

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.