HxHippy

alias

Create an alias for a command

Overview

Allows users to create, display, or remove command aliases. Aliases are shortcuts or custom names for longer or frequently used commands, improving efficiency and reducing typing.

Syntax

alias [NAME[=VALUE] ...]

Common Options

alias

Without arguments, displays all currently defined aliases in a reusable format.

alias NAME

Displays the definition of the alias specified by NAME.

alias NAME='COMMAND_STRING'

Defines an alias named NAME for COMMAND_STRING. Quotes are needed if COMMAND_STRING contains spaces or special characters.

unalias NAME

Removes the alias specified by NAME. (Note: `unalias` is a separate but related command).

Persistence

To make aliases permanent, add their definitions to your shell startup file (e.g., `~/.bashrc` for bash, `~/.zshrc` for zsh) and then source the file or open a new terminal.

Examples

$ alias

Shows all currently defined aliases.

$ alias ll='ls -alF'

Creates an alias `ll` that executes `ls -alF` (detailed list including hidden files).

$ alias update='sudo apt update && sudo apt upgrade -y'

Creates an `update` alias for system updates (Debian/Ubuntu).

$ alias ..='cd ..'

Creates `..` as a shortcut for `cd ..` (go to parent directory).

$ alias myip='curl ifconfig.me'

Creates `myip` to display your public IP address using `curl`.

$ alias rm='rm -i'

Creates an alias for `rm` that prompts before every removal (interactive mode).

$ unalias myip

Removes the alias named `myip`.

$ # To make 'll' permanent, add to ~/.bashrc (for bash):

alias ll='ls -alF'

$ # Then source the file:

source ~/.bashrc

aliasshortcutcommandshellbashzshunaliascustom