(ve):Create command-line alias on Ubuntu

  • This page was last modified on December 16, 2010, at 13:57.
The (mt) Community Wiki is a collaborative project. Any (mt) Media Temple customer or employee may contribute. Not all articles and/or content have been tested for accuracy by (mt) Media Temple.

For officially moderated and tested articles, be sure to visit our KnowledgeBase.

From (mt) Community Wiki

Contents

Requirements

This article assumes the following:

  • You have an Ubuntu LAMP stack on your (ve) Server.
  • You are familiar with connecting to your (ve) via SSH.


Overview

An alias can shorten an otherwise lengthy command or string of commands. The syntax is:

alias foo='bar'

For example, updating your packages is done with 'apt-get update && apt-get upgrade'. This is lengthy to type every time you want to update your installed packages. I have created an alias for this command string for getting updates on the repository servers and then the installed packages.

alias up='apt-get update && apt-get upgrade'


This will let you type 'up' into the terminal and produce the same results as if I entered the full string.

When you have created the alias, you will need to add the alias command you entered so as to make it permanent after reboots.

This can be done by adding a small tail to your alias command:

echo "alias up='apt-get update && apt-get upgrade'" >> ~/.bashrc


Convenient aliases

  • addapp='apt-get install --yes'