I am quite a newbie in using Postgres under Ubuntu. I have created a PostgreSQL database and now want to install the PostGIS extension for it so that I can import shapefiles and use the PostGIS commands. PostGIS is installed. I use the bash shell. Can somebody give me advice?


1 Answer 1


PostGIS is installed as an Extension to each Database.

Once you have created a database,

psql -c "CREATE DATABASE Your_Database_Name;"

you can install Extensions.

psql -d "Your_Database_Name" -c "CREATE EXTENSION postgis;"


psql -d "Your_Database_Name" [Enter]

Your_Database_Name=# CREATE EXTENSION postgis;

Then you can use ogr2ogr to push Shapefiles to the database, or run the PostGIS functions in your database.

  • You can also use shp2pgsql. You'll need to apt-get install postgis to get that since they have the client command line stuff like shp2pgsql and raster2pgsql in that package instead of as part of the regular postgresql postgis server package
    – Regina Obe
    Commented Mar 27, 2017 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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