Shell and environment

Command alias

Create a short name for the command

Linux · Bash examples · commands run on the selected server

When to use alias

Use alias to shorten interactive shell commands. An alias is shell configuration rather than an executable program, and it should not be treated as a portable automation interface across different shells.

Syntax

alias [NAME[=VALUE]…]

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

No arguments
Show aliases for the current shell.
NAME=VALUE
Define an alias; the value is usually enclosed in quotation marks.

Usage examples

Show aliases

alias

Aliases defined in the current shell are listed.

Create abbreviation

alias ll='ls -lah'

A convenient listing alias is created only in the current shell context.

Check definition

alias ll

The selected alias definition is displayed for inspection.

Notes and limitations

  • This is a shell builtin command; the created alias is valid in the current session until it is saved in its configuration.
  • In Bash, aliases are usually not expanded in non-interactive scripts; For parameters and logic, use functions.

Common questions and troubleshooting

Why does my alias disappear after reconnecting?

An interactive definition is not automatically saved. Persist it in the correct shell startup file only after reviewing that file's execution context.

Why does a script not recognize my alias?

Alias expansion differs by shell and interactive mode. Use functions or explicit commands for reliable scripts rather than depending on interactive aliases.

Further help

Options vary by version and distribution. Check the installed documentation with this command: help alias.