How to Create Command Shortcuts in Linux (alias)

alias creates a shortcut name for a longer command, saved for the duration of the shell session (or permanently if added to a shell config file).

Published October 1, 2026

alias defines a short name for a longer command, such as alias gs='git status'. Add aliases to ~/.bashrc or ~/.zshrc to keep them permanently.

How it works

Aliases are expanded by the interactive shell only, not in scripts. unalias removes one.

For arguments or logic, write a shell function instead.

Try it

alias ll='ls -lah'
ll
drwxr-xr-x 5 ada dev 4.0K .

Practical examples

Define and use

alias gs='git status'
alias ..='cd ..'

Persist

echo "alias ll='ls -lah'" >> ~/.bashrc
source ~/.bashrc

List aliases

alias

Function for arguments

mkcd() { mkdir -p "$1" && cd "$1"; }

Common mistakes

  • Aliasing over a command and breaking scripts (rm -i is fine, risky others not).
  • Putting aliases in the wrong rc file.
  • Expecting aliases to work in scripts.

Key takeaways

  • alias name='command'.
  • Persist in your rc file.
  • Functions for arguments.

FAQ

Bypass an alias?

Prefix with a backslash: \ls.

Which file for zsh?

~/.zshrc.

More Linux articles