Let's say I have the following alias in bash -
alias ls='ls --color=auto' - and I want to call ordinary
ls without options. Is the only way to do that is to unalias, do the command and then alias again? Or there is some nifty trick or workaround?
You can also prefix a back slash to disable the alias:
Edit: Other ways of doing the same include:
command ls as per Mikel.
Use the full path:
/bin/ls as per uther.
Quote the command:
'ls' as per Mikel comment.
You can remove the alias temporarily for that terminal session with
The alias is just a defined shortcut. In this example, the alias defined is the string
ls, which executes
ls --color=auto. If you don't want that behavior, you can call the binary
ls using the absolute path.
So executing just
/bin/ls will produce output without color because it is not the alias you defined.
You could also change the alias to something different, or add a new alias that executes just
ls without the color parameters.
Another way, building upon @uther's answer, is to use
$(which ...) or
`which ...` (using backticks
``) to automatically find the executable's path. This will work in
$(which ls) `which ls`
Undoubtedly, simply prefixing the command with a
\ is much shorter.
UPDATE: According to How to use `which` on an aliased command?, this doesn't seem to be reliable at all.
Personally, I just avoid defining aliases with the same names as commands, so
ls always invokes the actual command. I have aliases or functions for various combinations of options like
lg. (This means I need
unalias ls in my
I find that the OS's assumptions about which options I might prefer (overriding the assumptions of the designers of the
ls command itself) rarely match my own personal tastes. I happen to dislike the look of
ls --color=auto, and its legibility can vary greatly between black-on-white and white-on-black.
YMMV, and the other solutions are of course still good to know.
Typing the command in uppercase seems to work, like
LS, though I'm not really sure why.