How can I run original command that aliased with same name?
An alias for ls
command in ~/.bashrc
file aliased with this one:
alias ls='ls --color=auto'
then, when I run ls
command in terminal aliased ls
(ls --color=auto
) runs. but my question is how can I run original ls
only and only ls
alone without extra argument and without solving problem with deleting aliased entry? since when I delete this entry I can run it in simple ls
.
You can bypass aliases by the following methods:
the full pathname of the command:
/bin/ls
command substitution:
$(which ls)
the command builtin:
command ls
double quotation marks:
"ls"
single quotation marks:
'ls'
a backslash character:
\ls
Suspend alias expansion
You could also disable alias expansion for all aliases temporarily, without deleting them:
$ shopt -u expand_aliases
$ command -v ls
/bin/ls
To enable them:
shopt -s expand_aliases
$ command -v ls
alias ls='ls --color=auto'
Note that alias expansion is disabled by default in scripts, but set by default in interactive shells.
You can disable an alias using \
in front of command.
So to run the original ls
command you need to run it using \ls
For example
-
First creating alias of
ls
command.[guru@guru-Aspire-5738 /]$ alias ls='ls -l' [guru@guru-Aspire-5738 /]$ ls total 96 drwxr-xr-x 2 root root 4096 Sep 3 18:31 bin drwxr-xr-x 5 root root 4096 Sep 17 02:51 boot drwxr-xr-x 2 root root 4096 Sep 3 22:17 cdrom drwxr-xr-x 17 root root 4520 Sep 17 21:11 dev drwxr-xr-x 153 root root 12288 Sep 17 21:11 etc drwxr-xr-x 3 root root 4096 Sep 3 22:17 home lrwxrwxrwx 1 root root 37 Sep 8 21:31 initrd.img -> /boot/initrd.img-3.2.0-68-generic-pae lrwxrwxrwx 1 root root 36 Sep 3 22:18 initrd.img.old -> boot/initrd.img-3.2.0-
(and many more...)
-
Output of original
ls
using\
which override the alias.[guru@guru-Aspire-5738 /]$ \ls bin etc lib opt sbin tmp vmlinuz.old boot home lost+found proc selinux usr cdrom initrd.img media root srv var dev initrd.img.old mnt run sys vmlinuz [guru@guru-Aspire-5738 /]$