Quick take: The alias command creates shortcuts for longer commands: alias ll='ls -lh'. Run alias alone to list them, and add the line to ~/.bashrc to make it permanent across sessions.

Introduction

The alias command lets you give a short, memorable name to a longer command or a command with your favourite options. Aliases are one of the easiest ways to speed up daily work — but on their own they last only for the current shell, so making them permanent is the key step.

Syntax

The basic syntax of the alias command is:

alias [NAME='COMMAND']

Common Options and Parameters

The most useful options and parameters for the alias command:

OptionDescription
aliasList all defined aliases.
alias name='cmd'Create or redefine an alias.
alias nameShow the definition of one alias.
unalias nameRemove an alias.
unalias -aRemove all aliases.
\nameRun the original command, bypassing an alias.

Practical Examples

Real alias commands you can run today:

# Create a shortcut
alias ll='ls -lh'
# A safer rm that prompts
alias rm='rm -i'
# Update shortcut
alias update='sudo apt update && sudo apt upgrade'
# List all aliases
alias
# Remove an alias
unalias ll
# Make it permanent
echo "alias ll='ls -lh'" >> ~/.bashrc

Tips and Best Practices

  • Aliases defined on the command line vanish when you close the shell — add them to ~/.bashrc (or ~/.bash_aliases) to keep them.
  • After editing ~/.bashrc, run source ~/.bashrc to load the new aliases without reopening the terminal.
  • Prefix a command with a backslash (\ls) to run the real command, ignoring an alias of the same name.

Final Thoughts

alias turns long, repetitive commands into short shortcuts that make the shell your own. Define them, list them with a bare alias, and — most importantly — save them in ~/.bashrc so they persist. For shortcuts that need arguments or logic, graduate to a shell function instead.

FAQ: alias Command in Linux

How do I create an alias in Linux?+

Use alias name='command', for example alias ll='ls -lh'. It works immediately in the current shell. Add the same line to ~/.bashrc to make it permanent.

How do I make an alias permanent?+

Add the alias line to ~/.bashrc (or ~/.bash_aliases), then run source ~/.bashrc or open a new terminal. Aliases typed directly only last for the current session.

How do I list my aliases?+

Run alias with no arguments to see all defined aliases, or alias name to show one specific definition.

How do I remove an alias?+

Use unalias name to remove one alias, or unalias -a to clear them all for the current session. To remove it permanently, delete the line from ~/.bashrc.

How do I run the original command when an alias overrides it?+

Prefix it with a backslash: \ls runs the real ls even if you have an alias named ls. You can also use command ls.

Need help with Linux servers or infrastructure?

Work directly with Muhammad Irfan Aslam for Linux, Ubuntu, Docker, DevOps, cloud, CI/CD, or infrastructure support.

Hire Me for Support