Aliases and .bashrc
Your own shortcuts.
Do you type the same long command again and again? Give it a short nickname. That's an alias. And put your aliases in a special file, so they're ready every time you open a terminal.

- The same long command?
- Give it a nickname
- Save it for every terminal
Making an alias
Alias, a name, equals, and the command in quotes. Here, LL becomes LS dash LAH. Now typing LL runs the whole thing. And alias on its own lists all your aliases.
alias ll='ls -lah' ll Pictures total 64K drwxr-xr-x 2 sam sam 4.0K Jan 5 09:00 . drwxr-x--- 1 sam sam 4.0K Jan 5 09:00 .. -rw-r--r-- 1 sam sam 24K Jan 5 09:00 beach.jpg -rw-r--r-- 1 sam sam 31K Jan 5 09:00 party.jpg alias alias ll='ls -lah'
The .bashrc file
Aliases disappear when you close the terminal. To keep them, add them to dot bash RC, in your home folder. Bash reads it every time a new terminal opens. Here we append an alias with echo, and tail shows it was added. Source runs the file straight away, so we don't need a new terminal.
echo "alias update='sudo apt update && sudo apt upgrade'" >> ~/.bashrc tail -n 1 ~/.bashrc alias update='sudo apt update && sudo apt upgrade' source ~/.bashrc && alias update alias update='sudo apt update && sudo apt upgrade'
Popular aliases
People love sharing their aliases. A few classics. LL for a detailed listing. Dot dot, for CD dot dot. RM dash I instead of plain RM, so deletes always ask first. And a short name for updating the system. Just don't name an alias after a command you'll need in its normal form.
| key | value |
|---|---|
| ll | ls -lah |
| .. | cd .. |
| rm | rm -i, safer |
| update | sudo apt update && upgrade |
Summary
Aliases are nicknames for commands, and dot bash RC makes them permanent. Source reloads it. Next, packing files into archives.
Key takeaways- alias ll='ls -lah'
- ~/.bashrc
- source ~/.bashrc