Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've tried

sudo apt-get purge postgresql
sudo apt-get autoremove postgresql


sudo apt-get --purge remove postgresql

But after this dpkg -l | grep postgres gives me that:

pi  postgresql-9.1                            9.1.11-0ubuntu0.13.04                    amd64        object-relational SQL database, version 9.1 server
pi  postgresql-client-9.1                     9.1.11-0ubuntu0.13.04                    amd64        front-end programs for PostgreSQL 9.1
ii  postgresql-client-common                  140                                      all          manager for multiple PostgreSQL client versions
ii  postgresql-common                         140                                      all          PostgreSQL database-cluster manager
ii  postgresql-contrib                        9.1+140                                  all          additional facilities for PostgreSQL (supported version)
ii  postgresql-contrib-9.1                    9.1.11-0ubuntu0.13.04                    amd64        additional facilities for PostgreSQL
ii  postgresql-doc-9.1                        9.1.11-0ubuntu0.13.04                    all          documentation for the PostgreSQL database management system

And if I try to start psql:

psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

So, as I can see, postgresql is installed.

share|improve this question
I've tried sudo apt-get --purge remove all packages shown by dpkg -l | grep postgres and sudo apt-get install postgresql-9.1 . And it worked for me. – user1858864 Jan 10 '14 at 1:55
It works, but it is unneeded. Every package doing something with postgresql depends on postgresql-common, thus it is enough if you purge this package out by the apt. – peterh Jun 6 '15 at 11:37

You can remove PostgreSQL completely by running the following commands:

sudo apt-get purge 'postgresql-*'
sudo apt-get autoremove 'postgresql-*'
share|improve this answer

psql is from postgresql-client package. So - remove it using the full name of the package:

apt-get remove postgresql-client-9.1
share|improve this answer
It removes only the package files, but doesn't remove the configuration, etc. The packages remain in the system package catalog, although in an "r" (=removed) state, instead of "i" (=installed). – peterh Jun 6 '15 at 11:39
if there is need to remove configuration files - it's enought to use dpkg -P package to remove it. – undefine Jun 7 '15 at 21:12
apt-get --purge remove postgresql-common

With dpkg --info <packagename> you can see, which is required by this current package. In most cases, there is a simple package, which is needed by all. This can be removed with apt.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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