[26.04 TIP #2] How to launch graphical applications in sudo mode

[Updated on May 12, 2026]

Things have changed with the switch to Wayland. Some, such as GParted, won’t launch, while others, such as Nemo, cannot be used in administrator mode.

Don’t worry, all is not lost, this little workaround will let you run such apps in sudo mode.


Open a terminal and paste this line to create a “.bash_aliases” file at the root of your home directory to avoid cluttering .bashrc:

gedit .bash_aliases

Copy and paste this line to create an alias:

alias sd='_sd() { xhost si:localuser:root; sudo "$1" "$2" 2> /dev/null; }; _sd' # Launch a graphical application in sudo mode

Save and close the terminal.


The next time you open the terminal, simply type “sd application_name” — followed by a path if necessary —, like this, to launch apps with superuser permissions:

sd gparted
sd gedit /etc/fstab
sd nemo /usr/share/applications

Hi @jlb

I have a problem with that :

marc@Marc-ROG-JOY-Budgie26:/$ gedit .bash_aliases

** (gedit:19436): WARNING **: 11:27:04.965: Could not load Peas repository: Typelib file for namespace 'Peas', version '1.0' not found

** (gedit:19436): WARNING **: 11:27:04.966: Could not load PeasGtk repository: Typelib file for namespace 'PeasGtk', version '1.0' not found
marc@Marc-ROG-JOY-Budgie26:/$ sudo gedit .bash_aliases
Authorization required, but no authorization protocol specified


(gedit:20284): Gtk-WARNING **: 11:28:49.041: cannot open display: :1


:thinking:

Don’t worry, @Marc_Driver, 26.04 won’t stop complaining. :roll_eyes:

Don’t pay any attention to the whiners and add this alias to .bash_aliases:

alias gu='gedit 2> /dev/null' # Remove Gedit's complaints in "user" mode

gu .bash_aliases
gu .bashrc

… or, just for a little Shadok-style fun: :face_with_hand_over_mouth:

alias gedit='_gedit() { gedit 2> /dev/null "$1" ;}; _gedit' # Gedit in "user" mode

gedit .bash_aliases
gedit .bashrc

In any case, add 2> /dev/null to your aliases or command lines whenever your terminal complains.

I don’t worry, I’m happy…I have replies…

Even without the modification suggested, there is no more complaint from 26.04; with, it is the same result i.e. nothing

marc@Marc-ROG-JOY-Budgie26:~$ sd nemo
localuser:root being added to access control list
[sudo: authenticate] Password:             
marc@Marc-ROG-JOY-Budgie26:~$ 

Trust me, you should create two different aliases: gedit complains even when superuser privileges aren’t required.

After all, that was your question, wasn’t it?

Sure, I trust you and I have done it.

My question is : how to make this bloody 26.04 without complaint ?

for the complaint, there is no more. For the work, nemo does not open at all neither in administration mode if it is alone or in normal mode with the sd command, ok with a directory; for fstab, it works; for GParted it seems doing nothing (is it installed ? ).

My “sd” alias is only used to launch graphical applications like Nemo or GParted in superuser mode.

Nemo opens just fine in user mode, either from its launcher or the terminal.

As for GParted, it’s one of Ubuntu’s quirks: if it’s available in a live session, the installation uninstalls it — yes, I checked by following the process in terminal mode. Va comprendre ! :roll_eyes:

But I cannot launch it if it is not followed by a directory.

For example :

sd nemo

does not work.

You really are cursed, @Marc_Driver! :face_with_hand_over_mouth:

alias sd='_sd() { xhost si:localuser:root; sudo "$1" "$2" 2> /dev/null; }; _sd' # Launch a graphical application in sudo mode

This alias works like a small script; it collects two pieces of information entered by the user: the application to launch ($1) and an optional path ($2).
But while $1 is compulsory, $2 is not: see sd gparted.

For Nemo, it’s exactly the same, and sorry, it works:

Damned !

I tried again and again and always the same result.

But before sending this I checked my .bash_aliases and saved it again.

And now my “sd nemo” works :shushing_face: :thinking: :blush:

I hope it will continue in this way :smiling_face_with_sunglasses:

I’m glad it’s working for you too, but could you explain what you mean by that and what you changed?

@jlb

My line

alias gu='gedit 2> /dev/null' # Remove Gedit's complaints in "user" mode

was preceeded by # as a comment.

I really don’t know it changed something as I have not used

gu .bash_aliases
gu .bashrc

If you understand, please explain. :blush:

Thank you for helping me understand.

A hash symbol at the beginning of a line in this type of file disables it by turning it into a comment.
However, only you know why there was a hash symbol at the beginning of that line… :sweat_smile:

Yes I have done various tests while my device seemed capricious; this hash escaped to me… :shaking_face: