shift all running process from user1 to user2

0

I have presently all my process running by user1 id on my server . Now we have a new user user2 and we want all the process running by user1 to run by user2. This is done for consistency as all other host uses user2 What should be the things that i should follow and must do things ? Note that user1 and user2 both have root privileges.

RMG

Posted 2015-04-14T17:25:52.907

Reputation: 103

Answers

0

It's not clear if the processes can be restarted as the new user or not. Assuming the processes can be stopped and restarted, and that user1 will actually become superfluous after the change, then it's relatively straight-forward:

  1. backup (!)
  2. stop all the user1 processes
  3. create user2
  4. (optionally) move/copy all the user1 files, just to be clear that they now belong to user2 (as necessary)
  5. chown all the files from user1 to be user2 (as necessary)
  6. be sure no script explicitly refers to user1 by name (or id), or references ~user1 home directory. Make these scripts generic by using $LOGNAME or $HOME instead of the user name.

If any of the processes assume that the user has a specific id, then that is something to watch for (but unlikely to be the case). After, it's likely the case that user1 can be disabled/deleted.

michael

Posted 2015-04-14T17:25:52.907

Reputation: 879