alias
Sometimes typing commands can get really repetitive, or if you need to type a long command many times, it’s best to have an alias you can use for that. To create an alias for a command you simply specify an alias name and set it to the command.
$ alias foobar='ls -la'
Now instead of typing ls -la, you can type foobar and it will execute that command, pretty neat stuff. Keep in mind that an alias made this way only lasts for the current session. Close your terminal or log out of the server, and it is gone. To have it every time, open the following file with nano and put the alias line in it:
~/.bashrc
That file is read every time a shell starts, which is what makes the alias come back. There are a few such files and which one your shell reads depends on how it was started, but ~/.bashrc is the right answer almost always. The Startup files lesson in Your Environment covers the rest.
You can remove aliases with the unalias command:
$ unalias foobar
Exercise
Create a couple of aliases then remove them.
Quiz Question
What command is used to make an alias?
Show answer
alias