1 背景短: 运行使用的脚本时,notify-send "title" "message"预计会显示通知,但sudo ./script不会显示通知 在阅读并访问了许多页面之后,我发现运行我脚本的这部分(通知 - 发送部分)仍然可以通知用户。 问题: 因此测试这个su命令: su normal-user -c "echo $USER" root 为什么不回来 normal-user linux bash — 赛百斯 source
4 $ USER变量在您输入命令时不会在su运行之后展开。 su normal-user -c 'echo $USER'将产生预期的结果。单引号意味着$ USER在su之后才会扩展。 — Ciclamino source