If you are trying to learn and use the shell (terminal) on a Linux virtual server the alias command is a very useful tool. Think of it as a nickname or a acronym. The acronym ‘LOL’ generally means ‘Laugh Out Loud’ or your friends nickname ‘Jim-bo’ probably means his full name. This is a broad meaning but you get the idea.
In general terms the alias command takes values that your would normally have to type in each time and makes a shorter version of that typing.
You could go to the menu, accessories, and click on gedit the do a file / open and then navigate to the file you open a lot, notes.txt OR you could open a terminal and type in gedit ~/notes.txt OR you could create an alias by typing ‘alias notes=”gedit ~/notes.txt” then press enter.
After that each time you want to open the file notes.txt just type in notes in your terminal. Try it, you’ll see how fast things happen This is very simple example but you can start to see the power of the command.
If you read the section about the Google Command Line then you could see that using the alias command to shorten the task of viewing a document in your Google Docs.
Example: I have a document named bootlinux in my Google Docs and I want to see the contents without having to launch a browser, login, find it, then click on it, just to see it.
Instead I open a terminal and type ‘google docs edit –editor gedit “bootlinux’ and then press enter…..boom in a few seconds I have it open in gedit to read.
Well, this is to much typing so I create an alias by typing ‘ alias gdoc=”google docs edit –editor gedit “bootlinux”” ‘. Then when I need to see the contents of the file I just open a terminal and type gdocs and press enter. FAST.
This is not meant to edit the document but rather view and use the contents. I still need to use Google to modify or edit the text of the document, unless you have a Apps Premier Account.
If you download web sites for offline reading using an alias can keep the typing to a minimum. So something like this could be done: alias bl=”wget -mEkK http://www.bootlinux.org” would create an alias named bl and each time it’s run would download the site for off line reading.
Something else the alias command can do that’s really handy is to set switches to other commands to your preferred defaults. An example would be the df command that is in one of the posts. The default command, df, returns a less than intuitive data.
A more readable command would be to use the -h switch with df, so you would run df -h. You could set df to use this as the default by typing this: ‘ alias df=”df -h” ‘. Like they say “Try it, you’ll like it”.
In Linux if you want to copy in the terminal you’d use the ‘cp’ command. You can make this and other terminal commands more ‘DOS’ like. So you’d type: alias copy=”cp” Then the ‘cp’ command is now run as ‘copy’.
NOTE: The alias commands that you set will disappear when you logout. You can keep them permanent by editing your bashrc. I’m using Mint and put the command alias df=”df -” in the /etc/bash.bashrc file. I had to do this as su.