Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

My system config is as follows:

System (running on Amazon EC2)

Ubuntu 10.04

Postgresql-8.2 installed and it is working.

ubuntu@ip:~$ sudo /etc/init.d/postgresql-8.2 status:
Running clusters: 8.2/main

When I try to shutdown the server, I get the error:

ubuntu@ip:~$ sudo /etc/init.d/postgresql-8.2 stop
* Stopping PostgreSQL 8.2 database server
* Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 63.                         [fail]

Because of the above problem I am unable to do a clean uninstall of PostgreSQL. Any suggestion on how to fix this problem?

I have tried the following:

sudo apt-get autoremove postgresql-8.2
sudo apt-get -f install
sudo apt-get purge postgresql-*

None of them resolved the problem.

Thanks in advance

share|improve this question
Check if… helps you solving the problem. – Andy Friese Dec 16 '12 at 11:59

The permissions are wrong on one of your folders in your $PATH

do a

echo $PATH

and look at all your folders mine looks like


the folders are seperated by :'s

then cd to every folder and ls -l to see permissions

if the folder is not 755 (drwxr-xr-x) then do a

sudo chmod 755 sbin/

finally when you are sure you havent missed anything run your

sudo apt-get -f install

Hope this helped everyone!

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.