I am facing a problem with Ubuntu. Bash aliases like ll
are not working if I am logging to my system from SSH. It works fine after writing bash
as a command in the shell.
It used to work. What could be the problem?
echo $SHELL
/bin/bash
There are different sets of files where you can set those aliases depending on whether Bash was started as a login shell or not.
If you log into your machine (i.e. supply username and password), then Bash will always load /etc/profile
, and load the first of ~/.bash_profile
, ~/.bash_login
and ~/.profile
if it finds one of them.
If you start a new terminal from your machine, you will not start a login shell but a so-called interactive shell. This loads ~/.bashrc
, but none of the others above, and this is also where your alias will probably be stored.*
To load the contents of .bashrc
when you run a login shell, you should add the following to your ~/.bash_profile
:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
Reconnect via SSH, and the alias from ~/.bashrc
will be available.
* If it's not in this file, there might be other system-wide bashrc
files such as /etc/bash.bashrc
on Ubuntu. See: Environment Variables – Community Ubuntu Documentation