переложить весь запущенный процесс с user1 на user2

229
RMG

В настоящее время все мои процессы выполняются по user1идентификатору на моем сервере. Теперь у нас есть новый пользователь, user2и мы хотим, чтобы весь запущенный процесс user1выполнялся user2. Это сделано для согласованности, так как все остальные хосты используют. user2Какими должны быть вещи, которым я должен следовать и должен что-то делать? Обратите внимание, что user1и user2оба имеют привилегии суперпользователя.

0
См. Http://superuser.com/questions/56884/change-euid-of-running-process ott-- 9 лет назад 0

1 ответ на вопрос

0
michael

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.