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):
echo "alias ll='ls -lah'" >> ~/.bashrc
source ~/.bashrc
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).
| Option |
What it does |
Example |
-p |
Print all current aliases in a form suitable for re-execution (same as with no arguments). |
alias -p |
-a |
Remove all aliases of the current session at once. dangerous
|
unalias -a |
Nothing found. Try a shorter query.