Alias - An introduction tutorial on using the Linux alias command
http://www.linuxbyexample.com
One way to check that your web site is running, is to ping the web server that your site resides on, and see if you get a reply. The command for this is ping, followed by the number of times you want to connect to your server, specifying the web site address you want to test. Here
I am testing the
Linux By
Example web site
.
As you can see, the server is responding, meaning that the web site is up and running.
If I wanted to check this status out several times during the day, it would soon become tedious having to re-type this command every time.
I know there are different ways, which save you from having to re-type commands, i.e. like searching your bash history, but that's one of the things I like about Linux, there is usually more than one way to achieve the same goal.
Personally, I find it easier to create an alias for a given command sequence, if it's something I am likely to use on a regular basis.
To see what alias commands your system already has set-up, you can simply type alias at the terminal prompt, which will give you a list of the current commands, and what shortcuts they are assigned to. Here you can see the word grep has been remapped to use grep in conjunction with the colour switch, which saves you having to specify this option on each grep command, effectively giving you auto colour highlighting by default.
To create a new alias command, we simply type alias, followed by the letter or phrase we want to use, equals, followed by the actual command sequence we want to perform. The command sequence needs to be enclosed in single speech marks.
So in this example, you can see I am assigning the letter w to the ping command we used earlier. If we now just type alias again, we can see that the command has been set-up, and just typing w will check that our web site is responding.
If you need to remove the alias from the letter w, just use the un alias command, specifying which reference you want to stop using
. As you can see, the w reference has now gone from the listing.
Using the alias command in this way, only makes the aliases work for the current terminal session, and if your computer is rebooted, then the settings are lost. To make them permanent, you need to add them to your .bashrc file, which can be found in your home folder.
Here is my home folder, and under Linux all dot files are hidden by default, so you will need to use your file managers view options, to turn on hidden files. This
function is commanly assigned to the keyboard shortcut of control plus H.
Once the hidden files are made viewable, find the .bashrc file and open it in a text editor, here I am using gedit.
This is quite a long configuration file, so you need to use your text editors search facility, to search for the section which contains the default alias commands. Once found, you can create a new line, and enter the alias mappings you want to use, I am just going to paste in our ping example from earlier. Once you have saved the file, the new aliases will be available to you at all times.
If you would like more information on the alias command, there is a very good write-up on the Linux
Information Project web site (http://www.linfo.org/alias
.html)
Thank you watching, I hoped you found the video useful.
Please subscribe to get notifications of new videos. Coming up next, how to backup your files off site using the
Amazon S3 storage solution. Until then, goodbye.