This isn't the answer to your question exactly. But my guess is you are after the end result and not caring about the method so much. If so try
If not what was the exact command you ran that go you here? Cause it looks like sudo might be having issues with the postgres user.