Alias Power Tailoring Linux For You

The power to create alias commands in Linux is next to divine because it means you can completely adapt linux to your needs and preferences. An alias is simply a word that causes a command or series of commands to be performed. Linux allows you almost complete freedom to create any alias you please. To set an alias you simply type something similar too this
alias ab='ls -a'
This will set up an alias for the letters ab being the ls -a command. This means when you type ab at the command prompt you will execute the ls -a command so typing ab will list all the files in the current directory.
To create another alias simply type whatever letters or even a word that you want to use for the alias in place of the ab and put what ever command and switches etc. in place of the ls -a. Remember that you can execute multiple commands by separating each one with a ; for example cd hello; mkdir try ; ls -la will first change directories to the hello directory, then create a directory called try, then list all the files in long format. You can string together as many commands as you like but caution should be used not to inadvertently do anything harmful.
It may be a good idea to create an alias for deleting files that includes the -i switch and hence will prompt before deleting files. This can be achieved by doing something similar to the following
alias del='rm -i' This will create an alias named del that will execute rm -i when used. This is how some of the new Linux productions build in safe guards such as Red Hat's rm command is actually an alias for rm -i hence it will prompt before it deletes anything (unless the -f switch is used of course).
Another useful alias is one which will produce a colour listing. When executed links, directories and files all will be displayed in different colours (if you have a colour monitor of course it will serve no purpose on a black and white or monochrome monitor).
alias list='ls --color'
or
alias list='ls -al --color' (for long listing all files in color format)
If you have a black and white or monochrome monitor then try this alias
alias list='ls -F'
or for long listing all files
alias list='ls -alF'
This will produce a listing showing a character for each type of file type / means a directory, * means an executable file and @ for symbolic links.
As you can see the use off alias' is only limited by your imagination. Try a few out for yourself and see how useful a good alias can be. I use several myself and find them to be very handy.


 email me

 Linux Home    HOME
This site was designed and created by Earthen web master