New .bash_aliases file

One really handy thing you can do in your Ubuntu installation is to add a custom .bash_aliases file.Some background…

  • When you SSH into your server a number of commands and files are run. One of these is the .bashrc file which lives in the user’s home directory. This is custom for each user. So when I log in as root (see this post) the file /root/.bashrc is executed.
  • .bashrc calls .bash_aliases (in the same directory) which is then also executed.
  • Typically .bash_aliases contains various alias commands which map one command onto another. This means that you can for example map ll to ls -al. Overall this can make life easier to run common commands quickly.
  • While it may not be best practice, you can actually add anything to your .bash_aliases file to be run on logon. The reason why I add more than just aliases to this file is that I re-use the same .bash_aliases file in various installations (my NAS, my Raspberry Pi, …) and on all of these there are a few common startup tasks I want to run. I don’t want to have to add these to crontab manually on each installation and some of my installs are performed very frequently (e.g. the Raspberry Pi). So just maintaining one common .bash_aliases file is much easier.
Here is an extract from my .bash_aliases file. Feel free to copy any or all of this. There are also some links at the bottom of this post with great posts on a few forums where people have described what they put in their .bash_aliases file.
Note that if you make changes to your .bash_aliases file, you can reload it without logging out and in by running

Useful sources

Leave a Reply

(email optional)