I'm trying to replace the whoami
command with a script that's in ~/.local/bin/
. Is there a way to have my whoami get priority so that when I run whoami my script will run instead?
This is what I have in my ~/.profile
file
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
and this works!
On top of this file, it's written
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
So if you have ~/.bash_profile
or ~/.bash_login
remove them or merge them with ~/profile
. I don't have those files.
This is what my $PATH
looks like (shortened . . .)
$ echo $PATH | sed -r 's/:/\n/g'| cat -n
1 /home/shiplu/anaconda3/condabin
2 /home/shiplu/.sdkman/candidates/gradle/current/bin
3 /home/shiplu/.cargo/bin
4 /home/shiplu/.local/bin
5 /home/shiplu/bin
6 /usr/local/sbin
7 /usr/local/bin
8 /usr/sbin
9 /usr/bin
10 /sbin
11 /bin
12 /usr/games
13 /usr/local/games
14 /snap/bin
Check the path at line 4. It's before any other system bin directories.