为ubuntuKylin添加“管理员权限打开”右键选项
1、首先安装gksu,这个功能主要是显示输入管理员密码的图形界面。在ubuntu安装中心搜索“gksu”或“Graphical front-end to su and sudo”,选择安装即可。
2、进入 Home -> .local -> share -> nautilus -> scripts文件夹,(因为.local文件夹是隐藏的,得按Ctrl+H显示隐藏文件。)然后新建一个名为“open-as-root”的文件。
3、编辑文件内容如下(我用的是gedit图形编辑器,小巧方便。):
#!/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 pathif [ -e -n $1 ]; thenobj="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"elsebase="`echo $NAUTILUS_SCRIPT_CURRENT_URI | cut -d'/' -f3- | sed 's/%20/ /g'`"obj="$base/${1##*/}"fi# Determine the type and run as ROOTif [ -f "$obj" ]; thengksu gedit "$obj"elif [ -d "$obj" ]; thengksu nautilus "$obj"fi
exit 0
然后保存退出。
4、在终端输入以下语句更改文件权限:
cd .local/share/nautilus/scripts/ && chmod 0755 open-as-root
5、然后重启nautilus即可(使用命令nautilus -q)或注销即可(当然重启更适合没经验的用户)。