Ubuntu18.04如何让桌面软件默认root权限运行?

什么是gksu?

  • 什么是gksu:

Linxu中的gksu是系统中的su/sudo工具,如果安装了gksu,在终端中键入gksu会弹出一个对话框.

安装gksu:

在Ubuntu之前的版本中是继承gksu工具的,但是在Ubutu18.04中并没有集成, 在Elementary OS中连gksu的APT源都没有.

Ubuntu18.04 安装和使用gksu:

seven@seven-notebook:~$ sudo apt install gksu

在文件管理器中转到如下目录:

右键单击*.desktop文件, 选择属性,如下图设置即可:

Elementary OS安装和使用gksu:

但是在EOS中就没有那么好了, EOS中的右键菜单属性不支持设置命令...因此只好更改*.desktop文件了:

# 使用这个命令打开
seven@seven-notebook:~$ sudo vim /usr/share/applications/AndroidStudio.desktop
# 文件的内容
seven@seven-notebook:~$ cat /usr/share/applications/AndroidStudio.desktop 
[Desktop Entry]
Version=1.0
Name=AndroidStudio
Exec=/home/seven/Apps/android-studio/bin/studio.sh
Comment=gksu "AndroidStudio"     # 类似的添加这一行, 我也不知道井号是不是desktop文件的注释...
Terminal=false
Icon=/home/seven/Apps/android-studio/bin/studio.png
Type=Application
Categories=Development

安装gksu的相关问题, 有的系统没有gksu的APT源,以你采用如下解决方案吧!

# 报错信息
Building dependency tree       
Reading state information... Done
Package gksu is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'gksu' has no installation candidate

# 下载两个deb包
seven@seven-notebook:~$ wget http://mirrors.kernel.org/ubuntu/pool/universe/libg/libgksu/libgksu2-0_2.0.13~pre1-9ubuntu2_amd64.deb
seven@seven-notebook:~$ wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gksu/gksu_2.0.2-9ubuntu1_amd64.deb

# 安装deb包,可能会出错...别急往下看
seven@seven-notebook:~$  sudo dpkg -i /libgksu2-0_2.0.13~pre1-9ubuntu2_amd64.deb
seven@seven-notebook:~$  sudo dpkg -i /gksu_2.0.2-9ubuntu1_amd64.deb

# 安装以上两个deb包出错的解决方法
seven@seven-notebook:~$ sudo apt --fix-broken install

# 安装完成以后运行gksu进行测试
seven@seven-notebook:~$ gksu

# 可能会出现一下错误, 但是对话框是可以弹出来的:
Gtk-Message: Failed to load module "canberra-gtk-module"
Gtk-Message: Failed to load module "pantheon-filechooser-module"

# 下面是解决方法
seven@seven-notebook:~$ sudo apt install libcanberra-gtk-module 
seven@seven-notebook:~$ sudo apt-get install gtk2-engines-pixbuf

# 如果还是不行,那么:
seven@seven-notebook:~$ sudo cp /etc/profile.d/pantheon-filechooser-module.sh{,.bak}
seven@seven-notebook:~$ ll /etc/profile.d/pantheon-filechooser-module.sh
seven@seven-notebook:~$ ll /etc/profile.d/pantheon-filechooser-module.sh.bak 
seven@seven-notebook:~$ sudo vim /etc/profile.d/pantheon-filechooser-module.sh
seven@seven-notebook:~$ source /etc/profile.d/pantheon-filechooser-module.sh

# 如果还没好也不是个大问题...不影响使用...

至此,问题解决完毕,感谢Google, 我Baidu了一上午没找到答案,下午睡醒一Google就出来了...
参考链接(感谢各路大神qwq...):
[如何在ubuntu 18.04上安装需要gksu包的应用程序?]
http://www.kbase101.com/question/9934.html
[linux gksu用法]
https://www.cnblogs.com/kex1n/p/6002385.html
[Ubuntu以root权限运行IDEA]
https://blog.csdn.net/u013742788/article/details/67116075
[Linux 网易云音乐不能启动问题及解决 Failed to load module "pantheon-filechooser-module"]
https://www.cnblogs.com/cshunter/p/9175212.html
[pycharm打开脚本报错Gtk-Message: Failed to load module "canberra-gtk-module"]
https://www.cnblogs.com/duex/p/8280574.html
[Shadowsocks服务器搭建及优化解决方案,教你如何正确上网]
https://blog.51cto.com/xvjunjie/2071369

转载于:https://blog.51cto.com/xvjunjie/2318437

你可能感兴趣的:(Ubuntu18.04如何让桌面软件默认root权限运行?)