Thunar has an option to add context menu custom actions to open Terminal, or to open folders and files in different applications.
Could it be possible to add a menu custom action that would open Thunar itself as root?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityIt appears that this is indeed possible. Following are specific instructions to add such an action, taken from the Xfce site.
Opening a root Thunar
Name: Open a root Thunar here
Command: gksu thunar %f
File pattern: *
Appears if selection contains: Directories
As of 18.04 gksu
is no longer even included in the default repositories. The recommended way to do this now is as follows:
Name: Open as admin
Command: thunar admin://%f
File pattern: *
Appears if selection contains: Directories
Weirdly though, Polkit will sometimes ask for the password twice when you first use this command. The elevated privileges seem to persist for several minutes so you won't be asked for the password again if you use the command several times in a short space of time.
Be aware that this isn't true root. You can modify or delete any files that would require root privileges via this method, however any files you create will just have your default user permissions.
if gksu is not installed:
pkexec thunar %f
according to https://forum.endeavouros.com/t/thunar-open-as-root/6801/7
a dirty little trick i use because on my distro the "%f" will never be blatantly passed on to pkexe
create a newfile with the following
#!/bin/sh
# Super User Execute
# Gives PkExec current environmental variables
# and passes current parameters thru running shells to it.
#
# Use this file instead of gksu, gksudo, and, pkexe.
# /usr/bin/suxe
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY $1 $2 $3 $4 $5 $6
save it as: ~/suxe (note: some distros DO NOT like the ~/ shorthand for home folder access. So, use your actual path in this situation) e.g /home/Johnny/Documents/suxe
then make it an executable file in /usr/bin
sudo cp ~/suxe /usr/bin/suxe
make it executable
cd /usr/bin
su chmod -x ./suxe
now in Thunars' custom action use:
Name: Open with admin access
Command: suxe thunar %f
File pattern: *
Appears if selection contains: Directories
hope this helps
I found with UbuntuStudio 18.04 suxe thunar method works without the %f but only after right clicking on a thunar file/folder pane. Doesn't work when right clicking on the desktop.