One of the things I almost always forget to save when I am formatting or moving to a new computer are my Terminal aliases. I just never remember to look in my home directory for that little hidden file that keeps all the commands that I use on a daily basis.
When I first learned about aliases, some people said to put the commands here and others said to put them there. I’ll show you the easiest way to set up some aliases of your own.
Ubuntu
For this tutorial I am using the latest version of Ubuntu which is Ubuntu 10.10. Your mileage may vary, but I have done it this way for a while now so I’m sure it will work with whatever version you are using.
Open up Terminal by clicking Applications > Accessories > Terminal.
Type the following and then hit ENTER after each line.
1 2 | cd nano .bash_aliases |
Now you will be in the text editor called nano. This is where you will type in the aliases you want to have. Here is an example of how to format the aliases.
1 | alias NAME='COMMAND' |
Here are a few examples of aliases that I use.
1 2 3 4 | alias uu='sudo apt-get update && sudo apt-get upgrade' alias myssh='ssh -C USERNAME@YOUR.SERVERNAME.COM' alias ll='ls -l' alias la='ls -a' |
As you can see, there are many useful aliases that you can add. Enter all the ones you want and once you are done hit CTRL + X. It will then ask you if you want to save, type Y for yes. Now it is asking for your file name, we already specified that earlier when we opened the file so just hit ENTER to confirm that.
Almost done. Just close out of Terminal, when you re-open it your aliases will be ready to go.
Mac OS X
For this tutorial I am using the latest version of OS X which is OS X 10.6.6. Your mileage may vary, but I have done it this way for a while now so I’m sure it will work with whatever version you are using.
Open up Terminal by going to Applications > Utilities > Terminal. Or just click on your spotlight search icon in the top right hand corner of your screen and type Terminal. Just click on that and it will open.
Type the following and then hit ENTER after each line.
1 2 | cd nano .bash_profile |
Now you will be in the text editor called nano. This is where you will type in the aliases you want to have. Here is an example of how to format the aliases.
1 | alias NAME='COMMAND' |
Here are a few examples of aliases that I use.
1 2 3 | alias myssh='ssh -C USERNAME@YOUR.SERVERNAME.COM' alias ll='ls -l' alias la='ls -a' |
As you can see, there are many useful aliases that you can add. Enter all the ones you want and once you are done hit Control + X. It will then ask you if you want to save, type Y for yes. Now it is asking for your file name, we already specified that earlier when we opened the file so just hit ENTER to confirm that.
Almost done. Just close out of Terminal, when you re-open it your aliases will be ready to go.
So there you have it. An easy way to set up Terminal aliases in both Linux and Mac. Hope you learned something and found this useful. If you have any questions feel free to ask.


















