如何在 Linux 的 Nautilus 文件管理器中以管理员身份打开文件和文件夹
Nautilus 文件管理器

> 
> 了解如何在 Ubuntu 和其他 Linux 发行版的 Nautilus 文件管理器的右键菜单中添加“以管理员身份打开”选项。
> 
> 
> 


![](/data/attachment/album/202004/19/211224hurk01u0kuvqnpvn.jpg)


如果要以根用户身份打开或编辑文件，你总是可以在终端中执行此操作。但我知道有些人对命令行不适应。


桌面 Linux 通常为那些害怕终端的人提供方法避免命令行。


如果你必须以 root 用户身份访问文件夹或以 root 用户权限编辑文件，那你可以在 [Nautilus 文件管理器](https://wiki.gnome.org/Apps/Files)中以图形方式进行操作。


一个小巧优雅的 Nautilus 技巧能让你以管理员（也就是 root）打开文件和文件夹。让我向你展示如何做。


### 在 Nautilus 文件管理器的右键菜单中添加“以管理员身份打开”选项



> 
> 警告！请不要以 root 用户身份打开和编辑随机文件，因为这样可能会弄乱文件并导致系统损坏。仅在需要时使用它。
> 
> 
> 


我展示的是 Ubuntu 的步骤。你可以根据你的发行版的软件包管理器进行更改。


你必须使用终端（即使你不喜欢它）来安装 Nautilus 插件。请[确保已启用 Universe 仓库](https://itsfoss.com/ubuntu-repositories/)：



```
sudo apt install nautilus-admin
```

关闭并再次打开 Nautilus 文件管理器以查看更改生效。


![Right clock to see the “Open as Administrator” option](/data/attachment/album/202004/19/211253hvvqqdg77wrptpm5.jpg)


你也可以用 root 用户身份编辑文件。只需选择文件，右键单击它，然后选择“以管理员身份编辑”选项。


![Edit Files As Root Ubuntu](/data/attachment/album/202004/19/211256x7ewi1u4y74u77nu.jpg)


这两种情况下，系统都会提示你输入帐户密码：


![You need to enter your password, of course](/data/attachment/album/202004/19/211257ykcyu0ryj677z287.png)


差不多了。你可以享受 GUI 的舒适了。


如果你不想再以 root 用户身份运行 Nautilus，那么可以删除此插件。删除已安装但不再使用的其他东西总是没错的。


在终端中（没错，再一次在终端），使用以下命令删除 Nautilus 插件。



```
sudo apt remove nautilus-admin
```

顺便说一句，如果你在使用 [Ubuntu MATE](https://ubuntu-mate.org/)，你可以使用 caja-admin 代替 nautilus-admin。其他文件管理器可能会或可能不会提供此类功能。


我希望这个快速技巧对你有所帮助。随时欢迎提出问题和建议。




---


via: <https://itsfoss.com/open-nautilus-as-administrator/>


作者：[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
![Warp Terminal](/assets/images/warp-terminal.webp)


![Warp Terminal](/assets/images/warp-terminal.webp)

If you want to open or edit a file as root, you can always do that in the terminal. I know a few people don’t feel too comfortable with the command line.

The desktop Linux often provides ways to avoid the command line for terminal-fearing people.

If you are in a situation where you have to access a folder as root or edit a file with root privilege, you can do that graphically in [Nautilus file manager](https://wiki.gnome.org/Apps/Files?ref=itsfoss.com).

A neat Nautilus hack allows you to open files and folders as administrator, i.e. root. Let me show you how.

## Add ‘open as administrator’ option in right click context menu in Nautilus file manager

I am showing the installation steps for Ubuntu. You can change it as per your distribution’s package manager.

You’ll have to use terminal (even if you don’t like it) for installing the Nautilus plugin. Please [make sure that you have the universe repository enabled](https://itsfoss.com/ubuntu-repositories/):

`sudo apt install nautilus-admin`


Close and open the Nautilus file manager again to see the changes in effect.

![Open Folder As Administrator Ubuntu](https://itsfoss.com/content/images/wordpress/2020/04/open-folder-as-administrator-ubuntu.jpg)

You can also edit files as root the same way. Just select the file, right click on it and choose the “Edit as Administrator” option.

![Edit Files As Root Ubuntu](https://itsfoss.com/content/images/wordpress/2020/04/edit-files-as-root-ubuntu.jpg)

In both cases, you’ll be prompted to enter your account’s password:

![Authentication Pop Up Ubuntu](https://itsfoss.com/content/images/wordpress/2020/04/authentication-pop-up-ubuntu.png)

That’s pretty much it. You can enjoy the comfort of GUI.

In case you don’t want to run Nautilus as root anymore, you can remove this plugin. It’s always good to remove additional things you installed but you don’t use anymore.

In the terminal (yes, again), use the following command to remove the Nautilus plugin.

`sudo apt remove nautilus-admin`


By the way, if you are using [Ubuntu MATE](https://ubuntu-mate.org/?ref=itsfoss.com), you can use caja-admin, instead of nautilus-admin. Other file managers may or may not provide such a feature.

## More Nautilus tweaks

You can explore more such uncommon, [hidden features of Nautilus](https://itsfoss.com/nautilus-tips-tweaks/) in this article.

[13 Ways to Tweak Nautilus File Manager in LinuxNautilus, aka GNOME Files, is a good file manager with plenty of features. You can further enhance your experience by using these extensions, tweaks and tips.](https://itsfoss.com/nautilus-tips-tweaks/)![](https://itsfoss.com/content/images/wordpress/2022/07/customizing-GNOME-Nautilus-File-Manager.png)


![](https://itsfoss.com/content/images/wordpress/2022/07/customizing-GNOME-Nautilus-File-Manager.png)

I hope you find this quick tip helpful. Questions and suggestions are always welcome.