Remove _postgres user safely and completely from Mac /etc/passwd

0

I'm am attempting to reinstall PostgreSQL as I am unable to log into it at all. I realise I had installed it a long time ago using both the installer from the postgres website and brew install postgres. I have uninstalled both of these now:

However I have a _postgres user left in /etc/passwd:

$ grep post /etc/passwd
_postgres:*:216:216:PostgreSQL Server:/var/empty:/usr/bin/false

There are no userdel or usermod commands available on Mac (10.11 El Capitan) and the alternative seems excessively complex (but perhaps necessarily so?)

AJP

Posted 2017-05-18T20:18:53.590

Reputation: 201

Answers

2

Use the command brew remove postgresql. Or investigate the uninstall scripts manually.

Edit: Have you tried this?

  • Quit Postgres.app & drag it to the Trash

  • Delete the data directory (default location: ~/Library/Application Support/Postgres)

  • Delete preferences for Postgres.app by executing the following command: defaults delete com.postgresapp.Postgres2

  • Remove the $PATH config for the command line tools (optional): sudo rm /etc/paths.d/postgresapp

Edit 2: To delete a user from the command line, boot into single user mode. Hold Command-s at startup. Check the filesystem: /sbin/fsck -fy If no remaining errors, mount the filesystem: /sbin/mount -uw / Start up directory services: launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist Note that single user mode said to use com.apple.DirectoryServicesLocal.plist, but that didn't work -- this did. Find what groups the user belongs to: dscl . -list /groups GroupMembership | grep username -- repeat for each group except for the user's own group. Remove the group corresponding to the username: dscl . delete /groups/username (this may not be necessary -- you may get an error that the group doesn't exist; you can ignore it and go on). Remove the user account: dscl . delete /users/username At this point, you may wish to remove or archive the user folder in /Users. You may wish to remove the .AppleSetupDone file in /var/db to cause the Setup Assistant to run when next booted. Type reboot to reboot the system or shutdown -h now to shut down the system.

user2497

Posted 2017-05-18T20:18:53.590

Reputation: 188

thanks for the help. I have edited answer to make it clear I have already run this command – AJP – 2017-05-18T20:27:23.233

1Oh - well, perhaps then reading the install/uninstall scripts will not be helpful. – user2497 – 2017-05-18T20:28:15.480

1I once messed around in the guts of OSX, assuming a normal passwd/group configuration. Even then it was a filthy experience. Jobs certainly made FreeBSD weirder. – user2497 – 2017-05-18T20:34:13.967

Wow... that is intimidating. Thank you very much for your answer. Playing whack-a-mole with postgres has at some point resulted in success. When I reinstall with brew and ran createdb \whoami`` I can now login to a psql shell successfully :) Thank you very much for the detailed answer. I'm going to mark this as correct though I haven't summoned the courage to try it! – AJP – 2017-05-18T20:38:11.610

1It is prudent to perform a backup. I am not sure why they got rid of the classical passwd/group system, but it is certainly possible regardless of this obfuscation. When I went cavediving in OSX, I was also removing a user account that wouldn't be removed with conventional weapons, but that was long ago. – user2497 – 2017-05-18T20:44:45.467

1IIRC, on a multivolume setup, if you have your Users folder on another disk, you must invoke mount -uwa – user2497 – 2017-05-18T20:46:39.120