--get your your Linux knowledge
> Linux Reviews > Tips and Tricks >

alias - How to make aliases for frequently used commands

alias allows you to define shortcuts and synonyms for commonly used shell commands.

The basic usage is:

  alias newcommand='yourcommand -arguments'

If you want to start aterm according to your preferences with the command term, do something like:

  alias term='aterm -ls -fg gray -bg black'

If you want a quick alias like ll for a more informative file listing:

  ls -al --color=yes

Starting alias without any options lists the current aliases:

  alias ls='ll'
  alias ls -al --color=yes
  alias term='aterm -ls -fg gray -bg black'

Use unalias to remove an alias.

  unalias term

You can also make aliases for existing commands. If you want ls to show colors by default, do:

  alias ls='ls --color=yes'

These aliases can be put in your login script (.bash_profile or .profile depending on what shell you are using).

Gentoo Linux tips

  alias aemerge='ACCEPT_KEYWORDS="~x86" emerge'

Alias with variables

You can not make aliases with variables. But you can make functions, having a function in your .profile/.bashrc will work just like an alias. To use ssh to copy files to a location on a server you can use

  sendpic () { scp $*; }

thanks to mina

Copyright (c) 2000-2004 Øyvind Sæther. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled ["GNU Free Documentation License"].

Meet new people