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:
- backup (!)
- stop all the user1 processes
- create user2
- (optionally) move/copy all the user1 files, just to be clear that they now belong to user2 (as necessary)
chown
all the files from user1 to be user2 (as necessary)
- 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.
See http://superuser.com/questions/56884/change-euid-of-running-process
– ott-- – 2015-04-14T17:35:48.133