如何在 ubuntu 12.04 中始终以 root 身份运行 eclipse?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21130914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I run eclipse always as root in ubuntu 12.04?
提问by Obtice
When I want to run eclipse in my ubuntu, I have to open a terminal and go to eclipse directory and run "sudo eclipse" command. That's not so hard but in this case, I have to leave the terminal open, as long as eclipse is running. Is there any way so I be able to run eclipse as "root" simply by double clicking on it in desktop.
当我想在我的 ubuntu 中运行 eclipse 时,我必须打开一个终端并转到 eclipse 目录并运行“sudo eclipse”命令。这并不难,但在这种情况下,只要 eclipse 正在运行,我就必须让终端保持打开状态。有什么方法可以让我只需在桌面上双击它就可以以“root”身份运行 eclipse。
回答by Charles Stevens
If you want the app to always run as root
如果您希望应用程序始终以 root 身份运行
1) Pin the application to the launcher as normal.
2) Locate the applications .desktop file which will be in either:
/usr/share/applications/APPNAME.desktop
~/.local/share/applications/APPNAME.desktop
or somewhere else, use locate .desktop|grep APPAME
3) Open with gedit:
gksudo gedit /usr/share/applications/APPNAME.desktop
4) Change then line
Exec=APP_COMMAND
to
Exec=gksudo -k -u root APP_COMMAND
5) Save
This command will also keep your environment which is very usefull if you need to connect to others servers and use your private key.
此命令还将保留您的环境,如果您需要连接到其他服务器并使用您的私钥,这将非常有用。
To add a quicklist option to 'Run as root'
向“以 root 身份运行”添加快速列表选项
Follow steps 1, 2 and 3 above
按照上面的步骤 1、2 和 3
If the launcher currently doesn't have any other quicklist options, just append this to the end of the document
如果启动器当前没有任何其他快速列表选项,只需将其附加到文档末尾
X-Ayatana-Desktop-Shortcuts=Runroot
[Runroot Shortcut Group]
Name=Run as root
Exec=gksudo -k -u root APP_COMMAND
TargetEnvironment=Unity
回答by garry
#!/usr/bin/expect -f
cd /adt-bundle-linux-x86-20131030/eclipse
sudo ./eclipse
expect "password:"
send "password\r"
expect eof