0

How can I delete the User PostgreSQL?

"It says User could not be deleted running '/usr/sbin/userdel' failed: Child process exited with code 16"

postgres  2105     1  0 12:23 ?        00:00:00 /opt/PostgreSQL/9.4/bin/postgres -D /opt/PostgreSQL/9.4/data
postgres  2106  2105  0 12:23 ?        00:00:00 postgres: logger process                                    
postgres  2108  2105  0 12:23 ?        00:00:00 postgres: checkpointer process                              
postgres  2109  2105  0 12:23 ?        00:00:00 postgres: writer process                                    
postgres  2110  2105  0 12:23 ?        00:00:00 postgres: wal writer process                                
postgres  2111  2105  0 12:23 ?        00:00:00 postgres: autovacuum launcher process                       
postgres  2112  2105  0 12:23 ?        00:00:00 postgres: stats collector process                           
nuc       2672  2623  0 12:25 pts/1    00:00:00 grep --color=auto postgres
2
  • Are you sure all processes owned by this user were stopped? Do ps -ef|grep postgres. – Jos Mar 4 '15 at 11:17
  • @Jos I posted the output above. – empedokles Mar 4 '15 at 11:27
1

You can't delete a user while there are still processes running owned by that user.

If you don't want to uninstall PostreSQL but change its running user (which is not recommended), you should stop the server process first, then chown all files currently owned by postgres. Otherwise, uninstall the server (sudo apt-get purge postgresql) and then try userdel again.

5
  • I'd like to wipe it completely from my disk. But I can't find it in the software-center. – empedokles Mar 4 '15 at 11:34
  • I added that to my answer. Funnily enough you can uninstall the server while it is running (it will be stopped first). – Jos Mar 4 '15 at 11:41
  • Funnily it says it can't be found if I do: "nuc@nuc:~$ sudo apt-get purge postresql Paketlisten werden gelesen... Fertig Abhängigkeitsbaum wird aufgebaut. Statusinformationen werden eingelesen.... Fertig E: Paket postresql kann nicht gefunden werden." – empedokles Mar 4 '15 at 11:43
  • You missed a 'g' in postgresql. Ah, so did I. Apologies. – Jos Mar 4 '15 at 11:44
  • Thanks a lot. I could clean up the unneeded dependencies as well. – empedokles Mar 4 '15 at 11:48
1

we can see still postgres process are running first kill all the process and then try to delete user.

Run the below commands

sudo kill -9 `pgrep postgres`

sudo userdel -r postgres

or better to uninstall postgres software.

2
  • "nuc@nuc:~$ sudo kill -9 pgrep postgres kill: Argument konnte nicht analysiert werden: 'pgrep' nuc@nuc:~$ sudo kill -9 pgrep postgres" - Argument couldn't be analysed. – empedokles Mar 4 '15 at 11:37
  • just edited my answer this character was skipped `` by this html editor – PKumar Mar 4 '15 at 11:39

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.