In this article, we cover how to bypass the Bash alias. But, before that a bit about the Bash alias itself. alias is basically a shell built-in command-line utility. It is mainly used when we wish to use commands with specific options and arguments all the time.
And, entering the long commands every time is just a waste of time. So, what we do is create a shortened form for the command and use it every time the command is invoked.
alias acts as a shortcut for the command we can say. But, at times, instead of creating a shortened form of command that isn’t related to the command. We create an alias for the command itself.
Understand it with the help of an example. We use the ls command-line utility to list directory contents. Now, we create an alias for the ls command itself that executes: ls -al command.
In that case, every time we use the ls command it would execute ls -al. But, there could be times when we don’t want ls -al to execute. In other words, we want only the ls command to execute. And, that could be just a temporary requirement and we may not wish to make permanent changes to our configuration. That is where we are required to bypass the Bash alias.
How to bypass the Bash alias
Assumption: We assume that you have relevant entries in the ~/.bashrc file. In this case, it is:
alias ls='ls -al'
Solution I: Use full pathname for the command. We can get the pathname through whereis command:
whereis ls
/usr/bin/ls issue the command with full pathname then it should work.
Solution II: Use builtin command, i.e. command:
command ls
We can use the command prefix here.
Solution III: Use a backslash before the command itself:
\ls
Solution IV: Enclose the command in single or double quotes:
'ls'
or,
"ls"
Try different solutions and choose the one which fits your requirements. In conclusion, we have covered here how to bypass the Bash alias in Linux here.