drew.d.lenhart

programming, software, technology, anything on my mind...

Creating Custom Alias Commands in Linux

2014/10/01

This tutorial is for Ubuntu users. Creating your own custom commands can free up some typing time, especially if you do a lot of command line work. One of the most common commands on Ubuntu is using the "apt-get" command to download updates/install software. Instead of dialing in "sudo apt-get install application blah blah blah", wouldn't it be easier if there were a shorter command? Let's create some alias's!


Open up your ~/.bashrc file:

sudo nano ~/.bashrc

Scroll to the bottom and add something like the following:

alias aptin="sudo apt-get install"
alias aptup="sudo apt-get update" Now command aptin apache2 is the new custom command to install apache2, for example...
I use this frequently for custom python scripts:alias mastercontrol="python /home/drew/mypythonscript.py"

Remember the following convention:

alias NewCommandName="OldCommandName"

**May need to reboot after editing .bashrc file.

Alias's are not limited to Ubuntu. Depending on your flavor of Linux, you may need to hunt down the bash file. Enjoy!

-Drew