I want to reset my postgresql database back to its initial condition after install. Apparently initdb is the way to do this, but although the command has a man page, it doesn't seem to be anywhere on my Ubuntu 10.10 system.

Does anyone know how this is supposed to be done on Ubuntu?

  • initdb is somewhere on your system, PostgreSQL needs it to get started in the first place. Feb 10, 2011 at 15:29

2 Answers 2


Personally I think you would be better off sticking with the Ubuntu specific commands, pg_lsclusters, pg_dropcluster, and pg_createcluster. These wrapper functions handle all of the filesystem layout pieces, and call initdb where necessary. It's not that you can't use the direct commands, but I've seen a lot of people get in to problems where they bypassed pieces of the regular ubuntu/debian config and then ran into problems when certain assumptions weren't met. You have a packaging solution, take advantage of it.

  • 1
    For server software this is absolutely ass-backwards. I decide where my database data files go, not Ubuntu's overzealous re-packagers. This kind of nonsense is Exhibit A for not ever running a server on Ubuntu. Mar 25, 2013 at 20:21
  • 2
    @NoahYetter: the script doesn't prevent you from decide that; in fact, it gives you the -d switch for such purpose. There's plenty to rant about in Ubuntu, but having sane defaults shouldn't be one. May 10, 2013 at 16:09

http://ubuntuforums.org/showthread.php?t=694887 suggests you want to be looking in /usr/lib/postgresql/$postgres_version/bin where you should also find createdb, createuser and similar, if you need them.

Substitute your postgres version as appropriate, obviously!

(As a more general tip: locate initdb would probably have furnished you with the answer. I don't have an Ubuntu machine with PG installed to check either the answer or this fact, though!)

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.