How do we edit text files as root using GUI on F38 Workstation?

I’m trying to edit a text file in /etc/ but I only have read permission. I’m not very familiar with the CLI so I’m trying to find out how to edit this text root text file using the GUI.


nautilus admin:
gnome-text-editor admin:///path/to/file

A general principle for minimizing security risks is to stick with simple, time-tested software, which pretty rules out most GUI tools. In addition, when a system has problems the GUI may not be available. It is best to learn how to do basic file and directory operations in a terminal before you encounter a problem. Then there is emacs, a not-so-simple but powerful and well-tested editor that works in terminals and GUI environments.

For text files, many experienced linux users create a copy of the file, edit that with regular user privileges, then use command-line tools to replace the original file and set appropriate permissions. This is often combined with an informal journal used to document such changes.


A simple one would be nano. I like that one because he shows me on the bottom how to use it. In the meantime nano comes preinstalled in almost all distributions.


Someone on the Fedora Matrix channel recommended Nano and I ended up using that. This guide has the details for navigating it. Thanks for the input, everyone!

The “official” way is indeed to use the admin:// URI, but an elegant and safe way is

SUDO_EDITOR="/usr/bin/gedit -s" sudoedit <filepath>

I have a script, sedit, containing

2>/dev/null SUDO_EDITOR="/usr/bin/gedit -s" sudoedit "$@"

so sedit /etc/fstab would allow me to edit fstab in the Gnome text editor Gedit. Because of the requirement to enter the sudo password in the terminal, this cannot as such be incorporated in the applications menu.

That said, in practice, I find myself using sudo nano, but some people may find this usefull.

1 Like

I’d suggest setting SUDO_EDITOR in your script instead of EDITOR, in case the user has VISUAL set.

sudoedit chooses the editor in this order: SUDO_EDITOR, VISUAL, EDITOR


@jn64 Thank you for this very usefull advice. I adjusted this in my previous message.