Ok, you have to promise not to make fun of me if you’re going to continue reading. You promise? Pinky swear?
Alright then, here we go. Somehow or another, I managed to avoid knowledge of command aliases in Linux for over 13 years! I’m gonna give you a moment to let that sink in.
…
That’s comparable to using a web browser for years, but not knowing about bookmarks. Yes, I know those people exist, but I am not one of them. I have cursed their kind more times than I can count. (I DO NOT miss tech support)
I cringe to think of all the wasted keystrokes over the years. If I could get those back I could…… well I don’t know what, but it’s probably awesome.
If I can save just one person from typing “ls -la” over and over and over again, then this post has earned it’s keep. Here is what I’ve learned:
- To show all aliases, just type alias
- To create an alias, use this format alias name='command'
- For example: alias la='ls -la' would allow you to simply type “la” instead of “ls -la”.
F-A-N-T-A-S-T-I-C!!!
Now imagine my surprise the next day when all of my aliases were gone. Here’s a picture of me when it happened:
I googled up the answer for Debian, which was to add the aliases to my .bashrc file in my home directory. However, when I went to do that, I found this:
[note color=”#DDD”]/home/user/.bashrc
1 2 3 4 5 6 7 8 9 10 |
[...] # Alias definitions. # You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly. # See /usr/share/doc/bash-doc/examples in the bash-doc package. if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi [...] |
[/note]
I did as it suggested and created the file .bash_alises, and put my aliases there. After logging out and back in again, they took effect.