Hello word,
In this post, we will have a quick look at how to run the Nautilus file explorer as root when remotely connected to your Ubuntu machine via the xRDP Software. This specific question/topic has been raised multiple times and no real or satisfactory answer has never been provided. An answer or workaround has never been clearly provided. So, it might be time to have a look into this request and see if this is possible and which procedure or workaround needs to be used to make it happens.
This post is really a quick and dirty first investigation on this specific topic so do not expect to have an answer or the perfect answer.
Let’s move on…
Overview
If you are a regular reader, you know that you can use xRDP software package to perform remote desktop session against Ubuntu (and other Linux distributions). As you probably know, there are a number of actions that you would perform perfectly fine when locally logged on on your Ubuntu machine (like adding user accounts, change WIFI settings, running Nautilus as Root..) . However, once you perform your remote session, these actions become a problem. Ubuntu is using Polkit technology to “protect” your Ubuntu session by applying a set of policies that prevent users to perform actions when remotely connected to the computer. It’s possible to apply some exceptions and allow specific actions. Such approach have been demonstrated in the following posts
- xRDP – System Policy prevents changes when trying to add user in Remote Session
- xRDP – Cannot connect to WiFi Networks in xRDP session – System policy prevents WiFi scans. How to Fix it !
- xRDP – The Infamous “Authentication Required to Create Managed Color Device” Explained
However, one action that seems more complicated than other is to run Nautilus as root within remote session. We know that this is highly discouraged and not recommended to start GUI application under the root context. Whatever reason you need to run Nautilus as root, we are expecting that you know what you are doing and you are aware of the possible risk of such action.
Running Nautilus as Root
Why Running Nautilus as root ?
Ubuntu and Linux in general have been really good progress in term of desktop interface and GUI applications. More and more users are moving to Linux/Ubuntu operating system to test and play around. More users also have discovered the xRDP software and the possibility to perform remote desktop session against an Ubuntu machine. Some users are not that experienced with Linux and they still need to use the GUI (and more specifically Nautilus to navigate to their folder structure).
So, when a user needs to access a folder where administrative rights are needed and when logged on locally to the machine, you can have two possible scenarios
- either the user will see a popup dialog box telling that there is an error somewhere
Click on picture for better Resolution
- or the user will get prompted for credentials in order to proceed with elevated account
Click on picture for better Resolution
As a last resort, most of the users would try to run the Nautilus GUI app with elevated privileges through command line. They would simply issue the following command
sudo nautilus
The user will get prompted for credentials and the Nautilus would open fine and running with elevated privileges. The user will then be able to browse and navigate through all the Folder Tree structure. Some people needs indeed access to files that are restricted and they prefer the GUI approach. This is why some many people are asking to run Nautilus as root.
Note: There are other ways to start nautilus as root such as pkexec or nautilus-admin packages as well. The point here is that even if not recommended, people will try to start nautilus as root or try to get admin access to their folders within the GUI.
Running Nautilus as root in Remote Session
Up to Ubuntu 22.04 Version
As mentioned above, if a user tries to run the Nautilus GUI application as root in the remote session, the Oops Error message will be probably displayed.
Click on picture for better Resolution
Within the remote session, if the user tries to use the command line approach by issuing the su nautilus command, the following error message will appear
Click on picture for better Resolution
So, the standard approach that works when locally logged on does not work when remote connected. So, to overcome this limitation, we need to use a small workaround. Before running the nautilus command as root, we will need to use the xhost command (which is a server access control program for X Server). The command can be used to add or delete hostnames or user names to authorize connections to the X Server.
To make nautilus running as root, you will need to issue the following commands
xhost si:localuser:root sudo nautilus
You might get prompted for credentials. If everything is working as expected, you will see your Nautilus interface that is running as root
Click on picture for better Resolution
To revert back your changes, you will issue the following command in the Terminal Console
xhost -si:localuser:root
The Ubuntu 22.10 Case !
The workaround described above (i.e., xhost command) is working up to version Ubuntu 22.04. However, we have tried the same approach against Ubuntu 22.10 but it’s seems that this is not working. You can see in the screenshot belwo that the console will throw some errors and the Nautilus gui will never show up : -(
Click on picture for better Resolution
So, for Ubuntu 22.10, the old trick is not working at all and we need to find another workaround. If you look at the error message, it’s seems that the problem might be due to a bug but we have no more information at this stage. The only workarounds we can provide at this stage are
- use the command line (you can use the sudo -i to enter in root mode interactively)
- use an alternate file manager
As an alternate file manager, we have tried the Nemo one. To install this alternate file manager, you simply issue the following command
sudo apt-get intall nemo
When the installation is completed, you can try to run the alternate file manager using the following command
sudo nemo
Click on picture for better Resolution
Final Notes
This is it for this post !
So, yes we know that running GUI applications as root is not recommended and you should avoid it. However, we have been asked to see if it would be possible to run Nautilus as root when remotely connected to your Ubuntu machine. We have done some tests on multiple versions and we have noticed that the results differs. It seems that up to Ubuntu 22.04, it’s possible to run Nautilus as root within your remote session. However, in Ubuntu 22.10, starting Nautilus as root seems mission impossible. The error thrown at the console let suggest that there might be a bug which might be related to the GNOME Version in use in Ubuntu 22.10. So, it seems that using the command line provide the most flexible approach to access protected files and folders within remote session…
Please note that this is quick and dirty investigation of this specific issue an we are just providing this as initial information and food for thought 🙂
Hope this help
Till next time
See ya