Best practice to run Linux service as a different user

后端 未结 8 1318
甜味超标
甜味超标 2020-12-04 04:46

Services default to starting as root at boot time on my RHEL box. If I recall correctly, the same is true for other Linux distros which use the init scripts in

8条回答
  •  时光取名叫无心
    2020-12-04 05:24

    Just to add some other things to watch out for:

    • Sudo in a init.d script is no good since it needs a tty ("sudo: sorry, you must have a tty to run sudo")
    • If you are daemonizing a java application, you might want to consider Java Service Wrapper (which provides a mechanism for setting the user id)
    • Another alternative could be su --session-command=[cmd] [user]

提交回复
热议问题