If you want to make use of aliases on your data center Linux servers but are hesitant to modify your .bashrc file, the Addalias tool might be for you.
If your data center makes use of Linux, you are probably comfortable with the command line. But even with any level of comfort, there are times when you either don't want to type out certain long or complicated commands, or you simply can't remember every switch and option for a command. When that's the case, you might make use of aliases.
Aliases are an easy way to create a shortcut for a Linux command. Using the .bashrc file, you can place as many aliases as you need, in order to make your Linux administration a bit easier. If you're not one to manually edit that .bashrc file, there's an incredibly handy tool you can install that includes both a command line and GUI method for making the creation of aliases very easy. That tool is called Addalias and is a basic command line/GUI tool that does one thing and does it very well. With Addalias, you no longer have to manually create or edit your aliases via the terminal window.
Let's install and use Addalias. I'll be demonstrating on a daily build of Ubuntu 18.04 desktop (in order to demonstrate the GUI as well as the command line).
Before we can install the Addalias tool, we must first take care of a couple of dependencies. Open up a terminal window on your Linux machine and issue the following commands:
sudo apt update sudo apt install python-minimal sudo apt install python-qt4
With the dependencies out of the way, you can now install Addalias with the following steps:
- Back at the terminal window, issue the command wget https://github.com/isamert/addalias/archive/maste...
- Unzip that file with the command unzip master.zip
- Change into the newly created folder with the command cd addalias-master/src
- Install with the command python addalias.py --install
- Once the installation is finished, close the terminal window (or log out if this is a GUI-less server)
Usage - command line
Open a new terminal window, or log back into your GUI-less server. You can now use the Addalias tool. I'm going to first demonstrate how to add an alias from the command line and then from the GUI.
The command structure for adding an alias with this tool is:
addalias ALIAS COMMAND
Where ALIAS is the name of the alias and COMMAND is the actual command to be run. Let's say I have a particular server I secure shell into regularly and want to create a handy alias for the command ssh email@example.com. It's a simple command to remember, but if you're typing it over and over throughout the day, it might be helpful to just type server1 for the SSH command to run. To do this with Addalias, the command would be:
addalias -add "server1" "ssh firstname.lastname@example.org"
The above command would add the necessary alias into the .bashrc file. Close and re-open the terminal, or log out and log back in, and you can run the alias by simply typing server1.
Usage - GUI
From the terminal window, issue the command addalias -gui and the GUI window will open (Figure A).
This GUI couldn't be any easier. Type the alias you want to add in the Alias text area and then type the command to be run in the Command text area. Click OK and your alias is added.
The GUI includes the ability to easily edit current aliases. Click on the Edit Aliases tab, select the alias you want modify, click the Edit button, edit your alias (Figure B), and click OK when you're done.
And that's all there is to using Addalias.
An easier route to an easy task
I get it: Aliases are actually not that hard to create. However, there are those who'd rather not directly modify such configuration files, or those who just prefer a GUI tool whenever it's available. Either way, if you want to take advantage of aliases on your data center Linux servers, the Addalias tools makes this easy task even easier.
- How to monitor network protocol traffic on your data center Linux servers (TechRepublic)
- How to import an ISO image into Antsle for more data center flexibility (TechRepublic)
- How to connect RazorSQL database client to your MySQL server (TechRepublic)
- How to install a minimal Debian server (TechRepublic)
- Happy 25th birthday Red Hat Linux! (ZDNet)