Quick Tips #3: Creating Alias Commands
Making your life easier with alias! :)
Look at this command:
traceroute -4 -A -T -p 443 globo.com
You have 4 options and 2 parameters. Looks like a big command then sometimes you can forget an option or parameter. To make it easier, you can create an alias (Seems like a “shortcut”) for this entire command. How about if you change the above command for:
4trace443 globo.com
Much better, right? That’s the way the alias works. Let’s check it out!
First of all, let’s create the alias:
alias 4trace443=’sudo traceroute -4 -A -T -p 443'
I needed to use sudo because the option -T (Protocol TCP) claims for root privileges.
You can see the alias created by running the command alias.
Using the command…
Works like a charm!
But if I restart the machine, will I have this alias created? The answer is NO!
To make a permanent alias, you should insert this in the .bashrc file for your user.
After insert it, run the command source ~/.bashrc to activate it and voilá, you can restart your machine! :D
To make it more organized, you can create a specific file for all alias you have.
Now, you just need to mention this file in .bashrc like:
When the system reads the .bashrc file, the file .bash_aliases should be read as well.
That’s it! I hope it can help you.
See ya!