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.
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
~/.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
~/.bash_logout, if it exists.
When an interactive shell that is not a login shell is started,
bash reads and executes commands from
~/.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
So you should check if you have any of these files:
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
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
So it's a bit strange that this is not already working for you.
Depending on your needs, you might want to make
But it would be even better to just include lines adding
$HOME/bin to your
~/.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.