I would advise against placing your aliases directly in ~/.profile (which was suggested in the comments). The ~/.profile file is not specific to bash.
You should instead place your aliases in ~/.bashrc.
Why?
- .bashrc is guaranteed to be specific to bash (or at least any future variant of it)
If you set everything up correctly, all of your shells can follow a similar convention. So you can have .bashrc, .zshrc, .tcshrc, .kshrc, etc.
- If you're like me and enjoy playing around with all the different shells, you will find this very very helpful
How to Set It Up
Place the following code in ~/.profile.
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
This will ensure that ~/.bashrc runs if and only if you're using bash.
So ultimately, ~/.profile is involved; but you still benefit from having all your aliases (and any other bash-specific commands) in a bash-specific file. The reason you need to add this to .profile is explained here: What's The difference between the different scripts for bash?.
Then add your aliases and other commands to ~/.bashrc. If ~/.bashrc does not already exist, just create it either with touch ~/.bashrc
or vi ~/.bashrc
.
Remember to re-apply ~/.bashrc whenever you modify it. Otherwise, you won't see the changes. To do that, run this code:
source ~/.bashrc