fre*_*nte 7 terminal sudo bash osx-mountain-lion macos
我一直在尝试以不同的用户身份运行应用程序。
尝试 1
sudo -u otheruser open /Applications/TextEdit.app
启动应用程序,但它使用当前用户,而不是otheruser。
尝试2
login username
并su - otheruser
成功登录为otheruser,不同的用户活动监控器弹出,但类似open /Applications/TextEdit.app
回报的错误LSOpenURLsWithRole() failed with error -10810 for the file /Applications/TextEdit.app.
尝试 3
sudo su - otheruser -c /Applications/TextEdit.app/Contents/MacOS/TextEdit
似乎启动了该应用程序(它出现在由otheruser启动的 Activity Monitor 下)但是当停靠栏图标无限期地弹跳时会出现此错误:_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
问题
那么……我如何以不同的用户身份运行应用程序?
小智 4
在 10.8 Mountain Lion 上,这个问题的答案对我来说似乎并不完全正确。我认为 demure 在第 2 点有一个打字错误,除了“-”之外肯定还有别的东西。对我有用的是:你的尝试 3,没有su
和-c
。
sudo -u testuser /Applications/TextEdit.app/Contents/MacOS/TextEdit
Run Code Online (Sandbox Code Playgroud)
这将作为测试用户打开 TextEdit,我可以将文件保存到/
. 保存到 testuser 的用户文件夹不起作用,但这可能是因为我授予该帐户很少的权限,因为我将其用于其他测试目的。有趣的是,即使我在 KeyChain.app 中停用了 root 用户,我也可以以 root 身份登录。这似乎只影响从 root 登录桌面,而不影响终端登录。我保存为 testuser 的文件具有正确的拥有权限等设置。
$ cd /
$ ls -la | grep testuser
-rw-r--r-- 1 testuser staff 330 18 Okt 20:07 Untitled.rtf
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
19475 次 |
最近记录: |