First download latest version from :
> http://maven.apache.org/
> go to download
> download apache-maven-3.5.0-src.tar.gz
Execute following commands :
> sudo tar xzf apache-maven-3.5.0-src.tar.gz -C /opt
> cd /opt
> Create symlink
sudo ln -s apache-maven-3.5.0 maven
Next, set up Maven path system-wide :
> sudo gedit /etc/profile.d/maven.sh
> export M2_HOME=/opt/maven
> export PATH=${M2_HOME}/bin:${PATH}
Finally, log out and log in again to activate the above environment variables. To verify the successful installation of maven, check the version of maven::
> mvn -version
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T00:03:14+05:30)
Maven home: /opt/maven
Java version: 1.8.0_45, vendor: Oracle Corporation,
runtime: /usr/java/jdk1.8.0_45/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-862.11.6.el7.x86_64", arch: "amd64", family: "unix"
export PATH=$PATH:/opt/maven
. Then trymvn -version
. – Ethan Strider