3

How can I get the following command to change for the root user as well?

gsettings set org.gnome.gedit.preferences.editor create-backup-copy false

This command should disable gedit backup files. It seems to work for the current user "vagrant" as shown in the screenshot below, but not root.

enter image description here

It is important to mention that this command needs to be run as the current user "vagrant" as it is part of a script.

Ubuntu 12.04
Kernel 3.2.0-58-generic-pae
GNOME  3.2.1
Running Linux in a Vagrant VM on Windows 8 using Virtual Box
Maythux
  • 84,289

4 Answers4

4

If you wanted a root gedit to not create backups then simply disable in root's gsettings (editing root's gsettings should be done with care & in only some limited places).

sudo -i

then

gsettings set org.gnome.gedit.preferences.editor create-backup-copy false

Note that starting in 13.10, I'd probably stick to gksudo gedit or just use a cli editor such as nano.

Radu Rădeanu
  • 169,590
doug
  • 17,026
  • Thank you, yes this is correct. I was able to achieve the desired effect using "sudo -i gsettings set org.gnome.gedit.preferences.editor create-backup-copy false" I want this particular setting to apply to both root and the vagrant user – Shane Gramlich Feb 06 '14 at 00:49
2
sudo -i

This worked!

If you are confident that the current user has the appropriate privileges to sudo, then the following command will change the root users gedit preferences from the current user

sudo -i gsettings set org.gnome.gedit.preferences.editor create-backup-copy false

However, instead of disabling the backup files at all, you could relocate them to another folder. Rmano provided the following script:

mkdir ~/TILDEBACKUPS

#!/bin/bash

find $HOME/* -name TILDEBACKUPS -prune -or -name "*~" -print -exec mv {} $HOME/TILDEBACKUPS/ \;

Also, as pointed out by Rinzwind, scripting gsettings may require a lot of maintenance as schema names change.

Finally, there was a bigger mistake here that led me to even asking this question. Thanks to Radu Rădeanu, opening the file with "sudo gedit filename" will cause all sorts of issues discussed in Why user should never use normal sudo to start graphical application

A better way to open filename in gedit is:

gksudo gedit filename

Thank you for everyone's help

1

By the way, the way to clean all the backup files is not so complex... you can do it with this script:

#!/bin/bash

find $HOME/* -name TildeBackups -prune -or -name "*~" -print -exec mv {} $HOME/TildeBackups/ \;

...just run it and it will move all *~ files under your home folder to the TildeBackup folder on your home (which you need to create beforehand).

When you discover you needed a backup is too late...

Radu Rădeanu
  • 169,590
Rmano
  • 31,947
0

To disable it run the command:

sudo gsettings set org.gnome.gedit.preferences.editor create-backup-copy false

Now to clean your home from these files(files ending with ~) run this simple command:

find ~ -name "*~" -delete
Maythux
  • 84,289