I often open up documents with gedit, like gedit /etc/apt/sources.list and obviously, it would be read only as I'm not opening it as root.

But then, why is gedit still allowing me to edit the file, showing a very light "[Read Only]" mention in the title bar that probably everyone misses or at least me, and waiting for me to try saving after all changes I wanted are done, just to say "Hey! You cannot save. You lost time."?

Is there a way to either:

  • Have gedit block any edition of read-only files (so I won't loose time editing something I cannot save, my preferred and "natural" way of thinking)
  • Have gedit-saving be "uprighted" to get sudo rights when saving (so I don't waste the time I spent editing; but that would not "work" if the read-only comes from some other cause like RO support/mount)
  • 1
    You can save the file with a new name/location. And later run sudo cat new_file >orig_file to update the original file.
    – FedKad
    Jan 24, 2022 at 12:46
  • 2
    If you wish to code one of those features as an option, I am sure that the Gedit developers will welcome your contribution.
    – user535733
    Jan 24, 2022 at 12:52

1 Answer 1


Any system file that can be read by "others" can be opened by anyone on the system with any software that can open the file. That is how it is implemented by default. One theoretical way would be to turn read permissions for "others" off, but that may have unexpected side effects and I would not recommend it.

An easy way to achieve what you want would be to install the snap or the flatpak version of Gedit. Such version runs in a sandbox, and has no access to system files in the first place. Alternatively, use firejail to establish a sandbox for your editor.

With respect to have gedit "upighted": just be a bit more careful if you decide to work like root. And if, despite that, you suddenly are in a situation where you cannot save changes, then follow the advise given in the comments: save the file under a temporary name and then open your system file properly and paste the modified content.

Developers likely will not want to bother implementing a feature like that. 1) system administration usually is through the terminal for the professionals; 2) as a typical desktop user, you are not editing system files every day. Just take care in doing that the correct way each time, and if you forget to open a file correctly as root, that is easily corrected.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .