0

I created postgres using the useradd command without thinking twice about it. I've already got postgres installed and running. I'm unable to add a home directory to postgres because the user is currently logged in.

Can I somehow log the postgres user out and remove it? If I delete the user (and recreate it using adduser), will all of its files still belong to it (assuming same UID)? Are there other potential problems? If this won't work, can I at least log the user out so that I can set its home directory?

orokusaki
  • 2,693
  • 4
  • 28
  • 42

1 Answers1

3
  • No need to delete the account, better modify it to keep UID/GID of the files in sync with existing files.

  • Stop the database server if it is running, that is the reason that it appears to be "logged in".

  • Modify the home directory of the user using usermod(8), look in the manpage for the -d switch.

  • Start the server.

dawud
  • 14,918
  • 3
  • 41
  • 61
  • Thanks. The only problem is that I can't `usermod -d /home/postgres postgres` because `postgres` is currently logged in. How do I remedy that? – orokusaki May 31 '13 at 13:08
  • I already told you how. Stop the database server. If that is not enough, `kill` the remaining processes of the postgres user – dawud May 31 '13 at 13:36
  • It wasn't enough - I had to log the user out (or as you say, kill the remaining processes). However, even after making `/home/postgres/` (with the contents of `/etc/skel/`) the home directory and giving `postgres` recursive ownership, `su`-ing as `postgres` still resulted in a `$` command prompt (using `/bin/sh` vs `/bin/bash`)... so I nuked the entire server from orbit, and in the past hour I've set up an entirely new server, this time remembering to use `adduser postgres`. – orokusaki May 31 '13 at 14:54