How to uninstall postgre from Ubuntu 16.04
What are the commands I need to run, to uninstall postgresql from Ubuntu 16.04?
1 Answer
5 years ago by Eleven
1. Run dpkg -l | grep postgres
to list installed postgresql
Run the following command to list installed postgresql
dpkg -l | grep postgresql
This outputs something like following
ubuntu@ip-xxx-xx-xx-xx:~$ dpkg -l | grep postgresql
ii postgresql 9.5+173ubuntu0.1 all object-relational SQL database (supported version)
ii postgresql-9.5 9.5.17-0ubuntu0.16.04.1 amd64 object-relational SQL database, version 9.5 server
ii postgresql-client-9.5 9.5.17-0ubuntu0.16.04.1 amd64 front-end programs for PostgreSQL 9.5
ii postgresql-client-common 173ubuntu0.1 all manager for multiple PostgreSQL client versions
ii postgresql-common 173ubuntu0.1 all PostgreSQL database-cluster manager
ii postgresql-contrib 9.5+173ubuntu0.1 all additional facilities for PostgreSQL (supported version)
ii postgresql-contrib-9.5 9.5.17-0ubuntu0.16.04.1 amd64 additional facilities for PostgreSQL
2. Prepare uninstall command with all listed packages
collect all package names and form uninstall query
sudo apt-get --purge remove postgresql postgresql-client-9.5 postgresql-client-9.5 postgresql-client-common postgresql-common postgresql-contrib postgresql-contrib-9.5
This should uninstall postgresql from your Ubuntu 16.04 machine.
Uninstall output
These uninstall commands output something like following
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
gyp javascript-common libjs-inherits libjs-jquery libjs-node-uuid libjs-underscore libuv1 libuv1-dev linux-aws-headers-4.4.0-1035 linux-aws-headers-4.4.0-1060
linux-aws-headers-4.4.0-1075 linux-aws-headers-4.4.0-1077 linux-aws-headers-4.4.0-1079 linux-aws-headers-4.4.0-1083 linux-aws-headers-4.4.0-1084 linux-aws-headers-4.4.0-1085
linux-headers-4.4.0-1035-aws linux-headers-4.4.0-1060-aws linux-headers-4.4.0-1075-aws linux-headers-4.4.0-1077-aws linux-headers-4.4.0-1079-aws linux-headers-4.4.0-1083-aws
linux-headers-4.4.0-1084-aws linux-headers-4.4.0-1085-aws linux-image-4.4.0-1035-aws linux-image-4.4.0-1060-aws linux-image-4.4.0-1075-aws linux-image-4.4.0-1077-aws
linux-image-4.4.0-1079-aws linux-image-4.4.0-1083-aws linux-image-4.4.0-1084-aws linux-image-4.4.0-1085-aws linux-modules-4.4.0-1077-aws linux-modules-4.4.0-1079-aws
linux-modules-4.4.0-1083-aws linux-modules-4.4.0-1084-aws linux-modules-4.4.0-1085-aws python-pkg-resources
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
postgresql*
0 upgraded, 0 newly installed, 1 to remove and 160 not upgraded.
After this operation, 59.4 kB disk space will be freed.
Do you want to continue? [Y/n] Y
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 314357 files and directories currently installed.)
Removing postgresql (9.5+173ubuntu0.1) ...
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'postgresql' is not installed, so not removed
Package 'postgresql-doc' is not installed, so not removed
The following packages were automatically installed and are no longer required:
gyp javascript-common libjs-inherits libjs-jquery libjs-node-uuid libjs-underscore libuv1 libuv1-dev linux-aws-headers-4.4.0-1035 linux-aws-headers-4.4.0-1060
linux-aws-headers-4.4.0-1075 linux-aws-headers-4.4.0-1077 linux-aws-headers-4.4.0-1079 linux-aws-headers-4.4.0-1083 linux-aws-headers-4.4.0-1084 linux-aws-headers-4.4.0-1085
linux-headers-4.4.0-1035-aws linux-headers-4.4.0-1060-aws linux-headers-4.4.0-1075-aws linux-headers-4.4.0-1077-aws linux-headers-4.4.0-1079-aws linux-headers-4.4.0-1083-aws
linux-headers-4.4.0-1084-aws linux-headers-4.4.0-1085-aws linux-image-4.4.0-1035-aws linux-image-4.4.0-1060-aws linux-image-4.4.0-1075-aws linux-image-4.4.0-1077-aws
linux-image-4.4.0-1079-aws linux-image-4.4.0-1083-aws linux-image-4.4.0-1084-aws linux-image-4.4.0-1085-aws linux-modules-4.4.0-1077-aws linux-modules-4.4.0-1079-aws
linux-modules-4.4.0-1083-aws linux-modules-4.4.0-1084-aws linux-modules-4.4.0-1085-aws python-pkg-resources sysstat
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
postgresql-9.5* postgresql-common* postgresql-contrib* postgresql-contrib-9.5*
0 upgraded, 0 newly installed, 4 to remove and 156 not upgraded.
After this operation, 15.0 MB disk space will be freed.
Do you want to continue? [Y/n] Y
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 314354 files and directories currently installed.)
Removing postgresql-contrib (9.5+173ubuntu0.1) ...
Removing postgresql-contrib-9.5 (9.5.17-0ubuntu0.16.04.1) ...
update-alternatives: warning: forcing reinstallation of alternative /usr/share/postgresql/9.5/man/man1/postmaster.1.gz because link group postmaster.1.gz is broken
Removing postgresql-9.5 (9.5.17-0ubuntu0.16.04.1) ...
Purging configuration files for postgresql-9.5 (9.5.17-0ubuntu0.16.04.1) ...
Dropping cluster main...
Removing postgresql-common (173ubuntu0.1) ...
Removing 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Purging configuration files for postgresql-common (173ubuntu0.1) ...
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
dpkg: warning: while removing postgresql-common, directory '/var/lib/postgresql' not empty so not removed
Processing triggers for man-db (2.7.5-1) ...
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
gyp javascript-common libjs-inherits libjs-jquery libjs-node-uuid libjs-underscore libpq5 libuv1 libuv1-dev linux-aws-headers-4.4.0-1035 linux-aws-headers-4.4.0-1060 linux-aws-headers-4.4.0-1075
linux-aws-headers-4.4.0-1077 linux-aws-headers-4.4.0-1079 linux-aws-headers-4.4.0-1083 linux-aws-headers-4.4.0-1084 linux-aws-headers-4.4.0-1085 linux-headers-4.4.0-1035-aws linux-headers-4.4.0-1060-aws
linux-headers-4.4.0-1075-aws linux-headers-4.4.0-1077-aws linux-headers-4.4.0-1079-aws linux-headers-4.4.0-1083-aws linux-headers-4.4.0-1084-aws linux-headers-4.4.0-1085-aws linux-image-4.4.0-1035-aws
linux-image-4.4.0-1060-aws linux-image-4.4.0-1075-aws linux-image-4.4.0-1077-aws linux-image-4.4.0-1079-aws linux-image-4.4.0-1083-aws linux-image-4.4.0-1084-aws linux-image-4.4.0-1085-aws
linux-modules-4.4.0-1077-aws linux-modules-4.4.0-1079-aws linux-modules-4.4.0-1083-aws linux-modules-4.4.0-1084-aws linux-modules-4.4.0-1085-aws python-pkg-resources sysstat
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
postgresql-client-9.5* postgresql-client-common*
0 upgraded, 0 newly installed, 2 to remove and 154 not upgraded.
After this operation, 3360 kB disk space will be freed.
Do you want to continue? [Y/n] Y
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 313931 files and directories currently installed.)
Removing postgresql-client-9.5 (9.5.17-0ubuntu0.16.04.1) ...
Removing postgresql-client-common (173ubuntu0.1) ...
Purging configuration files for postgresql-client-common (173ubuntu0.1) ...
Processing triggers for man-db (2.7.5-1) ...
``
5 years ago by Karthik Divi