我可以通过使用右键菜单以root身份打开文件
使用sudo可以以root身份打开文件。 但是,如何右键单击文件并使其以root身份运行 ?
我正在使用鹦鹉螺。
您需要管理员扩展程序
$ apt-cache search nautilus | grep admin nautilus-admin - Extension for Nautilus to do administrative operations
使用sudo apt-get install nautilus-admin
安装它
我从这里测试了解决方案,它工作正常(运行14.04 / nautilus)。
要不发布纯链接答案:
-
安装
gksu
sudo apt-get install gksu
-
导航到
~/.local/share/nautilus/scripts
-
创建并打开一个空文件,以
open-as-administrator
命名,粘贴下面的脚本:#!/bin/bash # # this code will determine exactly the path and the type of object, # then it will decide use gedit or nautilus to open it by ROOT permission # # Determine the path if [ -e -n $1 ]; then obj="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" else base="`echo $NAUTILUS_SCRIPT_CURRENT_URI | cut -d'/' -f3- | sed 's/%20/ /g'`" obj="$base/${1##*/}" fi # Determine the type and run as ROOT if [ -f "$obj" ]; then gksu gedit "$obj" elif [ -d "$obj" ]; then gksu nautilus "$obj" fi exit 0
-
使脚本可执行
-
注销并重新登录,或运行:
nautilus -q
再说:脚本不是我的! 在http://ubuntuhandbook.org上找到了它