How to Use the alias Command

Let us say you execute the command ‘ls –alh’ every time you need a long listing of files and directories. Now you want a shortcut to do this. Fortunately, you can do so by using the command alias.

The alias command is useful for creating shortcuts for long commands or for correcting typing mistakes.

To create a shortcut for ls, you can do this:

$ alias ls=”ls -alh”

Now, everytime you execute ls command, it will be run as if you are executing the whole ls –alh command. Be reminded that this will replace the existing ls command. You may use a different name for the new shortcut like so:

$ alias ll=”ls -alh”

However, once you exit the current terminal, the alias will not be saved. To make the alias permanent, you may edit the .bashrc file in user’s home directory:

$ vi ~rai/.bashrc

Then insert the alias command after the line that says #system wide functions and aliases. Save and exit.

That should do it!