Maven only invokable from terminal while root
10,861
First need to grand ownership of the folder to myself:
sudo chmod -R 755 /usr/local/apache-maven-3.2.2/
Then I opened ~/.bash_aliases with:
sudo gedit ~/.bash_aliases
And I added:
alias mvn='/usr/local/apache-maven-3.2.2/bin/mvn
Thanks to @Ploutox for the right commands and I also did a bit of editing / corrections myself.
Author by
fIwJlxSzApHEZIl
Updated on September 18, 2022Comments
-
fIwJlxSzApHEZIl over 1 year
I'm following the directions laid out here: http://java.dzone.com/articles/installing-maven-304-ubuntu
Everything is in the right place and the sym link is working correctly.
However whenever I try to call mvn from the terminal, I get:
xyz@xyz-laptop:~/Desktop$ mvn The program 'mvn' can be found in the following packages: * maven * maven2 Try: sudo apt-get install <selected package>
But if I switch to root, then it works fine:
sudo su root@xyz-laptop:/home/xyz/Desktop# mvn [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.079 s [INFO] Finished at: 2014-07-30T18:11:54-07:00 [INFO] Final Memory: 5M/234M [INFO] ------------------------------------------------------------------------
I'm very sure this is an issue with permissions but I don't know what to set the folders permissions to as I've never hit this error before. This error is frustrating me as well:
xyz@xyz-laptop:/usr/local$ cd apache-maven-3.2.2/ bash: cd: apache-maven-3.2.2/: Permission denied
-
zargawy almost 10 yearsDid you install your program using
sudo
orsu -
? Usingsu -
will log you as root, so that may be where your problem lie. Concerning the permission, try usingsudo -R 777 /usr/local/apache-maven-3.2.2/
(you might want to tweak the 777 if you are not the only user). That will allow you to access the folder as a regular user. Then, edit your~/.bashrc
and add the aliasalias mvn='/usr/local/apache-maven-3.2.2/bin/mvn'
-
fIwJlxSzApHEZIl almost 10 yearsI did not use SU to install. I unpackaged the tar file and sudo cp to copy it to /usr/local. Your advice worked! Thanks! Small typo though I think you meant sudo chmod -R :D
-
-
kraxor almost 10 yearsThe 777 permissions are way too permissive for this scenario. This makes every file in
/usr/local/apache-maven-3.2.2/
both world writable (i.e. everyone can write them) and executable. Consider using 644 for all files and 755 for directories and files that are intended to be run. -
Carlos Sanchez Odreman about 6 yearsdo you need the alias if the mvn folder is in your path?
-
fIwJlxSzApHEZIl about 6 yearsShort answer: no. I wrote this a very long time ago but I'll try to help! If you type
which mvn
it should output the directory of the executable that will be executed if you type inmvn
. If you get nothing back you can either addmvn
to your path or you can create an alias. Both might achieve similar functionality when executing in a bash terminal but have different implications. If something is on your path - that means other things can find it more easily. If something is an alias that just makes it easier for you to execute on command as needed in a terminal.