Using a bash alias is awesome and super convenient, but sometimes it can conflict with other commands. This can be really frustrating when your terminal goes rogue and starts doing crazy things. I use a lot of aliases, and the first time I encountered this issue, I thought I had completely screwed up my bashrc file. After some head pounding, I finally realized, “Oh, this command conflicts with my alias.”.
OK, so you have a conflicting alias. What can you do about it?
In this situation, we need a way to temporarily disable or ignore the alias.
Here are 3 ways you can do that:
Disable Alias For A Session
One thing you can do is temporarily disable an alias for a single bash terminal session. You can achieve this by typing:
After this, you can use the command like normal, without worrying about an alias causing a conflict for the remainder of that terminal session. The great thing is that once you end that terminal session and start a new one, your alias will work again with no issues.
Prepend A Backslash
Maybe you don’t want to disable the alias. That’s fine. Instead, you can simply prepend a backslash to the command. For example:
This allows you to run any command with worrying about aliases. And, you don’t have to worry about disabling the command for the entire session. Lovely.
Use the keyword ‘Command’
This is similar to the last one, but instead of prepending a backslash, you can add the word command before your your bash ‘command’.
This looks like this:
That’s it! Now you don’t have to worry about your aliases conflicting with any other commands. I hope this was helpful.
You read more about aliases in the bash documentation.
If you enjoyed this content, check out the programming section for more awesome technical content.