Super User is a question and answer site for computer enthusiasts and power users. 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

I have added some cd blah blah commands as alias in my .bash_login so as to ease changing directories.It was working fine .Suddenly though none of the aliases in there work .It says command not found .I have no clue as to why all of a sudden it would stop working .Any suggestions?(I did reboot my system)

I apologize I actually meant to write .bash_login

share|improve this question
sounds like you have a syntax error before your alias definitions. Care to post your .bash_profile here? – glenn jackman Jul 27 '11 at 21:54
what happens when you source .bash_login? – user10580 Jul 27 '11 at 23:33
thanks user10580 I did source it and it worked. – Manish Jul 28 '11 at 17:26
up vote 2 down vote accepted

Aliases are not exported. That is, an alias defined in one shell is not part of the environment inherited by any child shells. Therefore, the best place to define aliases is in your ~/.bashrc, not in your ~/.bash_profile or ~/.profile, as the first will be sourced by any interactive shell while the latter two will be sourced only by login shells.

share|improve this answer

Use the alias command in the shell to confirm if they are truly getting created or not. Also, are you just using the Mac program? Somewhere in the options should be a setting that you can configure it to use what's called a login shell. That's how the .bash_profile file will be sourced.

share|improve this answer
I run 'alias' at the command prompt ....doesnt output anything .But i have everything in there my .bash_profile – Manish Jul 27 '11 at 22:02
@Manish, we need to find out where the "command not found" error is coming from. – glenn jackman Jul 27 '11 at 22:10
@glenn : how can I do that? let me know .....I probably cannot paste the entire .bash_login here bcoz its huge and contains copyrighted information – Manish Jul 27 '11 at 22:19
Well I found a temporary hack ....I copied everything into .bashrc and then ran bash . – Manish Jul 27 '11 at 22:32
You should probably read this section of the bash man page ( -- that talks about the startup files and which are invoked during the various ways you can start bash. – glenn jackman Jul 28 '11 at 2:13

If what you're trying to do is make changing directories easier, look at $CDPATH:

CDPATH The search path for the cd command.  This is a colon-separated list of
       directories in  which  the shell looks for destination directories
       specified by the cd command. A sample value is ".:~:/usr".

Using the example above, add the following to your profile:


Then if no matter what directory you are in you can easily get to child directories of ~ or /usr.

$ pwd
$ cd bin
$ pwd
share|improve this answer

The file .bash_profile is probably not being read by your shell on launch. Many distros have something like this in their default .bashrc:

if [ -f ~/.bash_profile ]; then
        . ~/.bash_profile

If all you're using it for is aliases, I woud recommend you name the file ~/.bash_aliases:

if [ -f ~/.bash_aliases ]; then
        . ~/.bash_aliases

All it does it checks if the file exists, and if so, executed the commands in it. In your case, the alias commands. Pop that in your .bashrc and your problems should be solved.

EDIT: Actually it's a little more complicated than that. My solution will work, but this is worth reading .bash_profile vs .bashrc

P.S. A reboot rarely is necessary to fix a problem on a *nix system. A logout and login at most.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .