≡ Menu

Bash Shell: Ignore Aliases and Functions When Running A Command

How do I ignore bash shell aliases or functions when running a command without removing alias or function from memory or current shell session on a Linux or Unix-like systems?

An alias is nothing but shortcut to commands. The alias command allows user to launch any command or group of commands (including options and filenames) by entering a single word. Aliases are mainly used for abbreviating a system command, or for adding default arguments to a regularly used command.

To view defined aliases the following commands can be used:

$ alias
Sample outputs:

alias cp='cp -i'
alias l='ls $LS_OPTIONS -lA'
alias ll='ls $LS_OPTIONS -l'
alias ls='ls $LS_OPTIONS'
alias mv='mv -i'
alias rm='rm -i'
alias apt-get='apt-get update && apt-get upgrade'

How to ignore aliases or functions when running a command?

Simply use command called command as follows to ignore aliases or functions. For example, on my system I’ve following aliases set:
alias apt-get='apt-get update && apt-get upgrade'
To ignore apt-get alias, enter:
command apt-get -y install
You can also use any one of the following syntax:
\apt-get -y install
"apt-get" -y install

Both \ and ” symbols allows you to run real apt-get command and ignore apt-get alias.

More about ‘command’ command

Runs COMMAND with ARGS ignoring shell functions. If you have a shell function called ls, and you wish to call the command /bin/ls command, you can type:
command ls
If the -p option is given, a default value is used for PATH that is guaranteed to find all of the standard utilities under UNIX / Linux:
command -p ls
The -V or -v option is given, a string is printed describing COMMAND. The -V option produces a more verbose description:
command -v ls
Sample output:

ls is aliased to `ls $LS_OPTIONS'

type command

Type command will print information about alias, function and real command:
type -a apt-get
Sample outputs:

apt-get is aliased to `apt-get update && apt-get upgrade'
apt-get is /usr/bin/apt-get
Further readings:
Share this tutorial on:

Like this? Follow us on Twitter OR support us by using Patreon

{ 4 comments… add one }
  • Planet Malaysia September 9, 2008, 9:00 am

    how about unalias?

    • Joe May 4, 2015, 3:48 pm

      You didn’t even read the first sentence, did you?

  • Philippe Petrinko April 2, 2010, 7:54 am

    Thanks Vivek – “command” is new to me.
    It is astonishing how Bash has become a swiss knife shell …

  • 0xmarcin January 14, 2017, 12:05 pm

    Great post! You saved my life!!!

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , ,