How to bypass aliases Linux command

This post will guide you how to bypass an alias in bash shell for a single Linux command. How do I temporarily bypass an alias in bash shell. How to disable an alias in bash shell.

Bypassing Alias Linux command


If you have defined an alias df for “df -h” command in bash shell, and you want to disable this aliase temporarily, How to achieve it. This post will introduce you four methods to bypass alias linux command.

Method1: You can quote your alias command to call the acutal command, type:

# "df"

Or

# 'df"

Outputs:

devops@devops-osetc:~/working$ alias | grep df
alias df='df -h'
devops@devops-osetc:~/working$ df
Filesystem Size Used Avail Use% Mounted on
udev 475M 0 475M 0% /dev
tmpfs 100M 3.7M 96M 4% /run
/dev/sda1 19G 4.7G 13G 27% /
tmpfs 496M 252K 496M 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 496M 0 496M 0% /sys/fs/cgroup
tmpfs 100M 60K 100M 1% /run/user/1000
devops@devops-osetc:~/working$ "df"
Filesystem 1K-blocks Used Available Use% Mounted on
udev 485408 0 485408 0% /dev
tmpfs 101576 3768 97808 4% /run
/dev/sda1 19478204 4892000 13573724 27% /
tmpfs 507876 252 507624 1% /dev/shm
tmpfs 5120 4 5116 1% /run/lock
tmpfs 507876 0 507876 0% /sys/fs/cgroup
tmpfs 101576 60 101516 1% /run/user/1000

Method2: Using command to call alias command

# command df

Outputs:

devops@devops-osetc:~/working$ alias | grep df
alias df='df -h'
devops@devops-osetc:~/working$ df
Filesystem Size Used Avail Use% Mounted on
udev 475M 0 475M 0% /dev
tmpfs 100M 3.7M 96M 4% /run
/dev/sda1 19G 4.7G 13G 27% /
tmpfs 496M 252K 496M 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 496M 0 496M 0% /sys/fs/cgroup
tmpfs 100M 60K 100M 1% /run/user/1000

devops@devops-osetc:~/working$ command df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 485408 0 485408 0% /dev
tmpfs 101576 3768 97808 4% /run
/dev/sda1 19478204 4892000 13573724 27% /
tmpfs 507876 252 507624 1% /dev/shm
tmpfs 5120 4 5116 1% /run/lock
tmpfs 507876 0 507876 0% /sys/fs/cgroup
tmpfs 101576 60 101516 1% /run/user/1000

Method3: Using Full Command Path to call Alias command

#/bin/df

Outputs:

devops@devops-osetc:~/working$ alias | grep df
alias df='df -h'
devops@devops-osetc:~/working$ /bin/df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 485408 0 485408 0% /dev
tmpfs 101576 3768 97808 4% /run
/dev/sda1 19478204 4892000 13573724 27% /
tmpfs 507876 252 507624 1% /dev/shm
tmpfs 5120 4 5116 1% /run/lock
tmpfs 507876 0 507876 0% /sys/fs/cgroup
tmpfs 101576 60 101516 1% /run/user/1000

Method4: Using Backslash to call alias command

You can also use backslash character to call alias command to bypass alias linux command temporarily, type:

# \df

Outputs:

devops@devops-osetc:~/working$ alias | grep df
alias df='df -h'
devops@devops-osetc:~/working$ \df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 485408 0 485408 0% /dev
tmpfs 101576 3768 97808 4% /run
/dev/sda1 19478204 4892000 13573724 27% /
tmpfs 507876 252 507624 1% /dev/shm
tmpfs 5120 4 5116 1% /run/lock
tmpfs 507876 0 507876 0% /sys/fs/cgroup
tmpfs 101576 60 101516 1% /run/user/1000

Unalias Command to Remove Aliases


If you want to unalias one alias linux command, you can use unalias command to remote alias. For example, type the following command to remote df alias command:

# unalias df

Outputs:

devops@devops-osetc:~/working$ alias | grep df
alias df='df -h'
devops@devops-osetc:~/working$ unalias df
devops@devops-osetc:~/working$ alias | grep df
devops@devops-osetc:~/working$

If you want to remove all alias commands in your current bash shell, you can execute the following command:

# unalias -a

Outputs:

devops@devops-osetc:~/working$ alias
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
alias rm='rm -rf'
devops@devops-osetc:~/working$ unalias -a
devops@devops-osetc:~/working$ alias
devops@devops-osetc:~/working$

 

You might also like:

Sidebar



back to top