alias — command shortcuts
cheat sheet · bash https://lab.dimsanych.ru/en/wiki/alias/Cheat sheet
-
alias ll='ls -lah'create -
aliaslist -
unalias llremove -
\cmd / command cmdrun the original, bypassing the alias -
echo "alias ..='cd ..'" >> ~/.bashrcmake it permanent
Options
alias barely has any flags: it takes name='command' pairs. The useful ones
are -p (print the list in a form suitable for re-execution, same as with no
arguments) and unalias -a (remove every alias of the current session at once).
An alias created on the command line lives only until you close the terminal.
To make it permanent, add it to ~/.bashrc (per user):
Ubuntu's default system aliases live in ~/.bash_aliases (sourced by
~/.bashrc). More on profiles and $PATH — env-vars.
An alias does not take arguments the way a beginner expects: alias gl='git log'
gets substituted before the rest of the line, so gl -5 works (it becomes
git log -5), but an alias cannot insert an argument in the middle of a
command — that needs a shell function (see bash-scripting).