I always want to run this /anaconda/anaconda3/bin/python executable whenever any of the system user runs below command:
python
python3
sudo python
sudo python3
I've modified /etc/environment file to below value
PATH="/anaconda/anaconda3/bin:/sbin:/bin:/usr/sbin:/usr/bin"
All which pyhton patterns returns the expected path
$ which python
/anaconda/anaconda3/bin/python
$ which python3
/anaconda/anaconda3/bin/python3
$ sudo which python
/anaconda/anaconda3/bin/python
$ sudo which python3
/anaconda/anaconda3/bin/python3
But when I run them with sudo, it is not executing /anaconda/anaconda3/bin/python
$ sudo python --version
Python 2.7.5
# This is I believe /bin/python
$ sudo python3 --version
Python 3.6.7
# This is I believe /bin/python3. This is certainly not `/anaconda/anaconda3/bin/python`
I want to execute /anaconda/anaconda3/bin/python when any of the user runs sudo python or sudo python3.
Does this mean /etc/environment isn't being able to change secure_path for sudo?
Please suggest a solution.
My OS is:
$ cat /etc/os-release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.5 (Maipo)"
...
...
