The command line terminal is a convenient and fast tool for interfacing with the Linux operating system. However, you may find yourself sending the same commands again and again while issuing instructions to your system. This may cost you a significant amount of time, especially if your commands are lengthy, hard to remember, or just repetitive. To help save time and reduce frustration, this guide shows you how to use the


command to create customizable shortcuts.

List Current Aliases

Most if not all systems have some aliases configured by default. You can list them by running the command


Here is the output from the default installation of Ubuntu 20.04:

alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'

Overwriting Command Names

It’s typical to create aliases with unique names that don’t conflict with other utilities or existing commands. You can also purposefully overwrite command names with


so they always take certain options, or replace them with different names. For example, you can have the


command run


instead. Or you can have


always run as

ls -lah

If you later want to run an original command without an alias, simply prepend


to the command. For example:


How to Create an Alias

There are two ways to create aliases for your use: temporary or permanent. Temporary aliases are only available to use until you close your current terminal session. Permanent aliases are saved to the shell configuration file and are available for every new session you create.

Create a Temporary Alias

Create a temporary alias by using the alias command followed by the shortcut and the command you want it to replace.

For example:

alias shortcut="your custom command"

For a more concrete example, say you want to create an alias to update and upgrade your system without having to type the entire command

sudo apt update && sudo apt upgrade

. You can make an alias for this called

alias update="sudo apt update && sudo apt upgrade"

To have the


command run



alias top="htop"

Create a Permanent Alias

Again, temporary aliases are only good for the current terminal session. Once you close that session, they are no longer available. To make them permanent, you can save your aliases in the shell configuration file. Depending on your shell, this file could be:

  • Bash: ~/.bashrc
  • ZSH: ~/.zshrc
  • Fish: ~/.config/fish/

The syntax for creating a permanent alias is the same as creating a temporary one. However, now you save it in the configuration file.

With your preferred text editor, open the appropriate configuration file, such as


. Enter one alias per line. While you can add your aliases anywhere in this file, grouping them together makes them easier to reference and adjust.

File: ~/.bashrc

alias update="sudo apt update && sudo apt upgrade"
alias top="htop"


Any newly added aliases are available for use in your next terminal session; they are not immediately available for any current sessions.

If you wish to use them right away in a current session, use one of the following commands as appropriate:

source ~/.bashrc
source ~/.zshrc
source ~/.config/fish/

How to Remove Aliases

To remove an alias, use the



unalias alias-name

For example, to remove the


temporary alias from above, enter:

unalias update

To remove all aliases:

unalias -a


Removing all aliases also removes the system default aliases.

Helpful Examples

Here are some helpful


examples that you may wish to save:

  1. To change quickly into a specific directory that you visit often, you can set an alias:
    alias docs="cd /Users/exampleuser/mydirectory/docs"
  2. If you work in Python, you can use these two aliases to create a virtual environment quickly:
    alias ve='python3 -m venv ./venv'
    alias va='source ./venv/bin/activate'
  3. Use this alias to find your external IP quickly:
    alias ipe="curl"
  4. If you use

    and wish to see the differences between your current branch the development branch (change


    to any other branch you wish to compare):

    alias gdd="git diff --name-only $(git merge-base $(git rev-parse HEAD) development)"
  5. Again, for

    if you want to view a list of your most recent branches:

    alias glh="git for-each-ref --sort=-committerdate refs/head | head"

Leave a Reply

Your email address will not be published. Required fields are marked *