There are a few question on the site that seem related to my problem but I could not find a solution in any of them.
My operating system is Ubuntu 12.04. I have
mvn installed in
/tools/noarch/apache-maven-3.1.1 and I have added the following lines at the end of my
export M2_HOME=/tools/noarch/apache-maven-3.1.1 export PATH=$M2_HOME/bin:$PATH
After that I execute
Now my problem is: when I run
mvn --version the command succeeds and
mvn executable is found, while if I execute:
sudo mvn --version I get the output:
sudo: mvn: command not found. I know that
PATH may be different when I execute a command with
sudo and that is why I tried this:
$>sudo echo $PATH /tools/noarch/apache-maven-3.1.1/bin:... some other stuff ...
Another thing I tried is to execute
sudo su - and then type
mvn --version. In this case
mvn is successfully found and the command succeeds. What is going on here?