Click the virtual machine below to start practicing
- Setting up virtual machine…
- Preparing lab files…
- Starting terminal services…
This lab machine has stopped
Your progress through the guide is saved. Start a fresh machine to keep practicing.
Click the virtual machine below to start practicing
Your progress through the guide is saved. Start a fresh machine to keep practicing.
An alias is a short name that expands to a longer command. You'll make one, save it, inspect it and remove it.
This lab is the hands-on companion to the alias lesson from Linux Journey (CC BY-SA 4.0).
alias lt='ls -lt'
lt
lt now runs ls -lt. It only lasts until this shell closes.
Bash reads ~/.bashrc when a shell starts. Add the alias there, then reload the file:
echo "alias lt='ls -lt'" >> ~/.bashrc
source ~/.bashrc
Use >> (append). A single > would wipe .bashrc.
alias with no arguments lists every alias, and type shows what one expands to. A backslash runs the original command, skipping any alias:
alias
type lt
\ls
Notice \ls has no colours: the colour comes from an alias.
unalias lt
type lt
bash: type: lt: not found
It comes back in new shells because it's still in ~/.bashrc.
alias name='command' creates a shortcut for this shell.~/.bashrc to keep them; source ~/.bashrc reloads it.alias lists aliases, type shows what a name is, and \cmd bypasses an alias.unalias name removes an alias.