如何提升nautilus权限以根目录移动或复制文件夹?

假设我在Nautilus中打开了一个文件夹,该文件夹位于我的/home/user/temp目录中。 我想将一个文件夹从那里移到我的/opt目录(这是一个程序)。 有没有办法可以将复制命令提升到sudo这样我就可以复制文件夹而无需从命令行启动Nautilus的新实例?

据我所知,根据我所知和所经历的经验:

sudo用于命令行应用程序/命令,当您尝试使用“ 运行应用程序”对话框窗口按Alt + F2 运行程序时, gksudo非常有用。

我读过gksudo只是sudo的图形版本。

无论如何,你可以在终端中放弃sudo nautilus和/或gksu nautilus 以达到你想要的目的,同时兼顾两个命令。 但是如果要省略终端并且希望直接使用“ 运行应用程序 ”对话框窗口运行它,只需按Alt + F2并编写gksu nautilus ,之后将提示您输入密码,然后输入nautilus文件浏览器将以root权限打开。

此外,通过右键单击“打开管理员”选项,您只需单击一下即可实现以root用户身份打开文件/文件夹。 在任何情况下都会为给定的文件夹打开一个新的nautilus实例并以root身份打开文件,这也可以以root身份打开/运行应用程序,但我还没有测试过它。

在此处输入图像描述

您可以通过命令行安装nautilus-gksu来sudo apt-get install nautilus-gksu上下文菜单中的“以管理方式打开”选项: sudo apt-get install nautilus-gksu或使用synaptic,如下图所示:

在此处输入图像描述

祝好运!

你需要以root身份运行Nautilus

在终端输入

 gksu nautilus 

现在你可以使用GUI移动了。

或使用此命令

 sudo mv -r /home/user/temp// /opt/ 

这是我用来打开管理员(root)Nautilus窗口的nautilus脚本:

 #!/bin/bash # This Nautilus script opens the current nautilus window in admin mode. # Requires: perl, liburi-perl ERROR_NEED_PERL="This script requires the liburi-perl package. Install it and try again." GKSUDO_MESSAGE="Enter your password to open an admin window on: " ERROR_BROKEN_LINK="Broken link." ## Check for liburi-perl (and hence perl) let PERLOK=$(dpkg-query -W --showformat='${Status}\n' liburi-perl|grep "install ok installed") if [ "" == "$PERLOK" ]; then zenity --error --text "$ERROR_NEED_PERL" exit 1 fi let LEN_NSSFP=${#NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}-1 [ $LEN_NSSFP -lt 0 ] && let LEN_NSSFP=0 let LEN_NSSU=${#NAUTILUS_SCRIPT_SELECTED_URIS}-1 [ $LEN_NSSU -lt 0 ] && let LEN_NSSU=0 ## if clicking happens on the Desktop (or a file or folder on it), ## $1 will be a path (ie with "/" in it); otherwise (in a folder ## window) $1 will be just a file or folder name (without path). ## Note that selecting the home desktop namespace extension yields ## a $# of zero but NAUTILUS_SCRIPT_SELECTED_FILE_PATHS pointing to the ## target (in the computer (computer:///) and trash (trash:///) desktop ## namespace extension cases, ...PATHS is empty). ## Initially, we stripped the file:// prefix from NAUTILUS...CURRENT_URI, ## yielding the full path, and then retrofit spaces, like this: #OBJECT="`echo -n $NAUTILUS_SCRIPT_CURRENT_URI | cut -d'/' -f3- | sed 's/%20/ /g'`" ## However, this fails if any special characters other than spaces are in the path, ## such as accented letters, etc. We need to convert not just spaces, but any ## UTF-8 embedded in there...The URI<->path conversion requires perl (and liburi-perl): OBJECT=$( echo "$NAUTILUS_SCRIPT_CURRENT_URI" | perl -MURI -le 'print URI->new(<>)->dir' ) ## ->file is to be used for file URIs instead of ->dir, which is for directory URIs CONTEXT="$OBJECT" ## Add the selection to the path, if defined and unique if [ $# -eq 1 ] ; then ## If a single Desktop object, override if echo $1 | grep -q "/" ; then ## Desktop (or object on desktop) OBJECT="$1" CONTEXT="" else ## $1 is a simple file or folder name, without a path ## The container could be root (/) OBJECT="${OBJECT%/}/$1" fi # elif [ $# -eq 0 -a -n "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ] ; then elif [ $# -eq 0 ] ; then ## desktop name space extension selected? if [ -n "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ] ; then ## Home OBJECT="${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS:0:LEN_NSSFP}" elif [ -n "$NAUTILUS_SCRIPT_SELECTED_URIS" ] ; then ## Computer, Trash ## These typically map to root (/) # OBJECT="`echo ${NAUTILUS_SCRIPT_SELECTED_URIS:0:LEN_NSSU} | cut -d'/' -f3- | sed 's/%20/ /g'`" OBJECT="${NAUTILUS_SCRIPT_SELECTED_URIS:0:LEN_NSSU}" OBJECT=$( echo "$OBJECT" | perl -MURI -le 'print URI->new(<>)->dir' ) fi CONTEXT="" fi ## Note that a desktop shortcut (.desktop file) does not trip -h if [ -h "$OBJECT" ] ; then ## symbolic link ## readlink has no "follow symlinks as far as they exist" option OBJECT=`readlink -e "$OBJECT"` if [ -z "$OBJECT" ] ; then zenity --error --text "$ERROR_BROKEN_LINK" exit 1 fi fi # zenity --info --text "\$OBJECT is « $OBJECT »" if [ -f "$OBJECT" ] ; then ## Regular file DIR=`dirname "$OBJECT"` else ## Directory (or no object) DIR="$OBJECT" fi ## If DIR is empty, gnome-open opens in the default (home) directory (ie "~") anyway #if [ -z "$DIR" ] ; then # DIR=~ #fi ## At this point, the test [ ! "$CONTEXT" = "$DIR" ] serves to indicate ## that the target directory is not matched to the one the script was ## invoked from (if any). gksudo --message "$GKSUDO_MESSAGE$DIR" gnome-open "$DIR" exit $? 

另一个花花公子的解决方案是从命令行启动具有root(sudo)权限的Nautilus的另一个副本:

 gksudo xdg-open  & 

结束&表示命令作为后台作业运行; 因此使用gksudo (使用sudo意味着你无法回应的隐形提示)。 xdg-open负责启动资源管理器窗口( nautilus或其他)。

您可能需要事先安装xdg-utilsgksu软件包。

关闭boost的Nautilus窗口后,你可能会得到一堆警告和Gtk-CRITICALGlib-GObject-CRITICAL消息,但据我所知,这些消息是无害的。 如果有人知道如何,我很想摆脱它们。

 sudo mv /home/user/temp/[Filename] /opt 

而不是[Filename] ,而不是括号[]键入文件的名称。

另一个简单的方法是

 sudo gnome-open foldername 

或者我建议安装nemo文件管理器。 它在右键单击上下文菜单中以“以root身份打开”