我正在运行 Ubuntu 18.04.2 LTS,并全新安装了transmission-daemon
. 它作为 Systemd 服务运行良好。但是当我尝试独立运行它(服务停止)时,我看到:
~ ⌘ sudo -u debian-transmission transmission-daemon -f --log-error --log-info --log-debug
[2019-05-14 11:53:19.167] Couldn't read "/home/jason/.config/user-dirs.dirs": Permission denied
[2019-05-14 11:53:20.419] Couldn't create "/home/jason/.config/transmission-daemon": Permission denied (file-posix.c:189)
[2019-05-14 11:53:20.419] Couldn't create "/home/jason/.config/transmission-daemon": Permission denied (file-posix.c:189)
[2019-05-14 11:53:20.419] Couldn't create "/home/jason/.config/transmission-daemon": Permission denied (file-posix.c:189)
[2019-05-14 11:53:20.419] Transmission 2.92 (14714) started (session.c:740)
[2019-05-14 11:53:20.419] Couldn't read "/home/jason/.config/transmission-daemon/stats.json": No such file or directory (utils.c:238)
[2019-05-14 11:53:20.419] Couldn't read "/home/jason/.config/transmission-daemon/stats.benc": No such file or directory (utils.c:238)
请注意,~
确实解析/home/jason
为用户jason
(我)。但我以用户身份运行它debian-transmission
。那么为什么传输试图访问“我的”用户目录呢?我怎样才能阻止它这样做?
至少在最新版本的 Ubuntu 中,
sudo
配置为保留调用用户的HOME
环境变量1。您可以通过执行类似的操作来验证这一点或通过运行
sudo sudo -V
并查看该Environment variables to preserve
部分。为了设置
HOME
为目标用户,您可以添加-H
(--set-home
) 选项:前任。