alias
a shortcut for a commandalias gives a command a nickname. Type the short name and the shell replaces it with the full command. An alias lasts only for the current shell unless it is written into ~/.bashrc.
If you type it ten times a day, give it a two-letter name.
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
Most distributions define a few. This is why grep shows colour and ll works without you having set anything up.
From now on, in this shell, gs runs git status. Quote the command so the spaces are kept together.
It reports that ll is an alias and what it expands to.
Appending the line to ~/.bashrc defines the alias in every new shell. Run "source ~/.bashrc" to load it now.
Switches
A switch changes how the command behaves. These are the ones used day to day; man alias lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.
-p- Print all aliases in a form that can be reused as input.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
alias rm='rm -i'Makes rm ask before each removal.
\lsA leading backslash runs the real command, ignoring any alias.
unalias -aRemoves every alias from the current shell.
alias ports='ss -tulpn'A memorable name for a command with awkward switches.
In cybersecurity
An alias means the command you type may not be the command that runs.
Someone with write access to your .bashrc can alias sudo to a script that records your password and then runs the real sudo. Check with "type sudo".
alias rm='rm -i' is not there in scripts, under sudo, or on the next machine. Do not let it teach you to type rm carelessly.
~/.bashrc and ~/.profile run at every login. They should be writable only by you.