This is happening because when you log in via SSH, the shell you get is a login shell. In contrast, to use the terminology from the bash documentation, when you open a Terminal window in an already-started graphical login session, the shell you get is still an interactive shell but it is not a login shell.
From man bash:
When bash is invoked as an interactive login shell, or as a
non-interactive shell with the --login option, it first reads and
executes commands from the file /etc/profile, if that file exists.
After reading that file, it looks for ~/.bash_profile,
~/.bash_login, and ~/.profile, in that order, and reads and
executes commands from the first one that exists and is readable. The
--noprofile option may be used when the shell is started to inhibit this behavior.
When a login shell exits, bash reads and executes commands from the
file ~/.bash_logout, if it exists.
When an interactive shell that is not a login shell is started,
bash reads and executes commands from /etc/bash.bashrc and
~/.bashrc, if these files exist. This may be inhibited by using the
--norc option. The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc
and ~/.bashrc.
So you should check if you have any of these files:
~/.bash_profile
~/.bash_login
~/.profile
If you do, then you should edit the first one you find and make it add $HOME/bin to your path. If you don't, create one of them for this purpose. (The best one to create is ~/.profile since other shells will use that too.)
You almost certainly have ~/.profile, since Ubuntu's default behavior is to create this with any new user account (including the first account, created when you install Ubuntu).
However, by default this file already contains the necessary lines to add your private bin directory to the $PATH:
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
So it's a bit strange that this is not already working for you.
Depending on your needs, you might want to make ~/.profile (or ~/.bash_login or ~/.bash_profile) call ~/.bashrc:
source ~/.bashrc
But it would be even better to just include lines adding $HOME/bin to your $PATH in ~/.profile (or ~/.bash_login or ~/.bash_profile), but not ~/.bashrc. After all, if you do this for every login shell, it should also happen when you log in graphically, and be inherited by all your interactive shells that aren't login shells.
echo $PATH– user unknown Jun 6 '12 at 0:23$PATHis not actually set, do you mean that when you runecho $PATH, there is no output at all? – Eliah Kagan Jun 6 '12 at 1:02. ~/.bashrcorsource ~/.bashprofile– user unknown Jun 6 '12 at 1:05