3

My Ubuntu version is Ubuntu 22.04.2 LTS. I have one user (ahmet) and it is member of sudo. I download intellij idea and I want to use its mvn lib for everyone. I edited /etc/bash.bashrc as in this link https://linuxhint.com/add-path-permanently-linux/ . When I try to execute mvn, there is three situtations:

normal way:

ahmet@ahmet:~$ mvn -v
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /opt/idea-IU-231.8109.175/plugins/maven/lib/maven3
Java version: 11.0.18, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.19.0-41-generic", arch: "amd64", family: "unix"

as root:

ahmet@ahmet:~$ sudo su
root@ahmet:/home/ahmet# mvn -v
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /opt/idea-IU-231.8109.175/plugins/maven/lib/maven3
Java version: 11.0.18, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.19.0-41-generic", arch: "amd64", family: "unix"

with sudo:

ahmet@ahmet:~$ sudo mvn -v
sudo: mvn: command not found

In my opinion, with "sudo mvn -v", everything must be same for root (#). But in this case, root can execute but normal user which is member of sudo, cannot use mvn with sudo. What is the problem?

1 Answers1

0

When you run sudo mvn -v directly from your user account, the system does not find the mvn command because the mvn executable directory is not included in your user's PATH.

You can add the full path to /root/.bashrc to fix this.

Like this

export PATH=$PATH:/opt/idea-IU-231.8109.175/plugins/maven/lib/maven3/bin