linux - 使用特定用户执行服务 - Ubuntu/CentOS

标签 linux ubuntu service centos rhel

我试图在不运行 sudo 命令的情况下执行服务并传递特定用户。

如果我使用 sudo 命令,应用程序将创建一个具有 root 权限的临时文件,当服务以正确的用户(应用程序用户)重新启动时,应用程序用户将无法访问此临时文件。

独立于启动此服务的用户,该过程需要从应用程序用户开始。

有什么办法可以解决吗?

我的操作系统是 Ubuntu 16 和 CentOS 6/7。

谢谢

最佳答案

将启动命令放入 sudo 并使用 su - c applicationuser/full/path/to/app 和 args

su -c NAME 将运行以下命令,就好像由 NAME 调用一样

您可以通过将命令放在 shell 脚本中然后将 shell 脚本放在 sudo 中来稍微清理一下。

关于linux - 使用特定用户执行服务 - Ubuntu/CentOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41215389/

相关文章:

angular - 注入(inject) MdDialogRef 的测试组件正在调用服务

c++ - 在 Windows 服务的控制台中显示消息

c - 通过 snprintf 在 C 中填充静态字符串缓冲区

linux - 如何永久设置GOPATH环境变量

python - bash脚本替换html中的空格

linux - 如何将 stderr 传输到 stdin?

php - Apache 服务器: can't render php and html at once

android - Sqlite 数据库更新触发 Service 通过 Content Observer 更新

linux - 多重连接会提高网速吗?

linux -/proc/net/tcp 中 tx_queue & rx_queue 的单位