I wanted to install an GRASS extension through a shell script but, upon execution it says:

You don't have permission to install extension to . Try to run g. extension with administration rights (su or sudo) sudo : : command not found

That been said I tried to execute this line of code:

add_on="$(g.extension extension=i.segment.uspo operation=add)" sudo "$add_on"

I know that I've done something wrong, but I don't know what.

Grass Version: Grass 7.0

Linux dist: Ubuntu 16.04 LTS

  • Which operating system do you use? And, which GRASS GIS version? Please add this to the question.
    – markusN
    Jun 11, 2017 at 20:03

2 Answers 2


So the main problems were two.

1) As a newbie I didn't know that I had to install "grass-dev" and I solved it by typing:

sudo apt-get install grass-dev 

2) It was my mistake that I forgot to change the ownership for my Grass folder by typing:

sudo chown -R $usern $EXT_ADDONS



is username:group and


is the Grass directory

and in case there is an error where a file cannot be downloaded for whatever reason (i.e /var/cache/apt/archives/grass-dev_7.0.5-1~xenial1_amd64.deb) you can fix it by typing

sudo dpkg -i --force-overwrite 'file'

in the case of our paradigm

sudo dpkg -i --force-overwrite /var/cache/apt/archives/grass-dev_7.0.5-1~xenial1_amd64.deb

which isn't usually the best idea, but it will make grass-dev work


I was successful installing add-ons via the command line with:

 grass -text -c EPSG:4326 --exec g.extension extension=i.segment.uspo operation=add
  • This is a good answer, although it won't work as is. The text flag should be --text and, the location and mapset need to be set in advance. This can be circumvented with the --tmp-mapset flag, i.e.: grass --tmp-mapset --exec g.extension extension=i.segment.uspo operation=add Apr 22 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.