When doing
which python, I am getting /usr/bin/python.
When doing
which python3, I am getting /usr/bin/python3.
However, When doing alias python=/usr/bin/python3, still which python returns /usr/bin/python.
This makes me think there is some more elaborate logic to finding bash commands, but I was not able to look it up, probably I am not aware of its name.
So, how does bash find commands?
EDIT to answer comments
see output of alias
noam@ML:~/src/uv-car-parts-segmentation$ which python /usr/bin/python noam@ML:~/src/uv-car-parts-segmentation$ which python3 /usr/bin/python3 noam@ML:~/src/uv-car-parts-segmentation$ alias python=/usr/bin/python3 noam@ML:~/src/uv-car-parts-segmentation$ 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 python='/usr/bin/python3' noam@ML:~/src/uv-car-parts-segmentation$ which python /usr/bin/python Here is the doc about how commands are resolved, which appears not to be the solution to this.
alias|grep pythonshow?whichcommand itself was aliased on my machine (CentOS 8). Look at this:alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'. Running/usr/bin/which pythonwithout the command flags confirmed the behaviour you saw. The answer by @ilkkachu is correct.