I have observed that in gedit if I edit a file, another file is created in the same directory (the one with the same filename and a tilde '~' suffix). The extra file remains even if I close gedit.

I understand the need for a temp file (eg. in case of a crash), but vim for example deletes the extra file it creates, when I close it.

Is there a way to do the same with gedit? Some configuration perhaps?

  • 4
    Here's a plugin idea. Instead of saving the backup files to the same directory as the file, the backup files are saved to /tmp/gedit.bak/ or some other directory so they don't pollute your working directories. – user57345 Sep 19 '12 at 17:29
  • I like it, but is it even implementable? – Lewis Goddard Sep 19 '12 at 19:53
  • 1
    At the same time, change the tab with to 4, which should be the default. Eight is too much, and it is a nuisance to delete the extra spaces, while pressing two times tab, in case it is needed, is easy. They have been with that stupid value for years and years.... – Pili Garcia Sep 19 '12 at 20:29
  • By the way: if you do find ./ -name "*~" -ok rm {} \; you can find and remove them. The ok means you'll be asked about every file. If you're more bold, -exec will just do it, no questions asked. – Amanda Mar 4 '14 at 13:52

Those are just backups of your original files that gedit creates before saving changes to your edited documents.

In gedit preferences you need to disable Create a backup copy of file before saving, and if you want to automatic save your edits automatically set a timer with the option enable Autosave files every X minutes.

That way the ~ will be gone and your last changes will be saved on the file every x minutes in case something goes bad or your computer crashes.

enter image description here

The changes made to the file will be saved to the file itself and not to a temporary file.

Please be aware that if you delete the contents of a file and auto save is enable there will be a chance that you end up with a saved empty file.

Always make sure that when you close on file while auto save is enabled that the contents of the file are correct, else undo them and save the file again.

  • Also if you want to avoid that from root user run gksu gedit and disable Create a backup copy of file before saving option too. – αғsнιη Oct 16 '14 at 6:45

GEDIT by default has an option enabled which creates a backup file (with the suffix ~ for the backup file) every 10 minutes. You can easily disable this default behavior.

Go in the gedit menu to Edit > Preferences > Editor, there you will find an option that says Create a backup of files before saving. Uncheck this option and you are done.

There is another option below that one called autosave files every .. minutes. I mention this one since some people like to have the backup option enabled but prefer to autosave less often, like 30 minutes or 1 hour as opposed to the default 10 minute interval.

In any case to disable the ~ (tilde) preceded file creation just disable (uncheck) the Create a backup of files before saving

A view of the Editor options in gedit:

screenshot of Editor options

  • 1
    Thx, though it's not exactly what I want. Vim for example creates a temp file, and deletes it afterwards. So if something happens I can recover the file. If I disable that from gedit, I won't be able to recover something that I didn't save before the crash. – George Kastrinis Nov 26 '11 at 22:50
  • 1
    @GeorgeKastrinis creating a backup file before saving does not save any temporary changes to the file while working, only when you press the save button or the shortcut key to save the file it will save the previous rev of the file. ie: if you are working for 1 hour and did not save the file in the mean while and crash your work will be lost. – Bruno Pereira Nov 26 '11 at 23:11
  • @BrunoPereira I don't actually know what gedit does with its backup file; just that it creates it. From my experience with vim, I did know that its temporal file (.swp) does save temporary changes and can be used for recovery. Anyway thx for the infos ;) – George Kastrinis Nov 27 '11 at 13:24

You may be able to turn off these automatic backups by going into Edit > Preferences and unchecking the Create backup copies of files before saving option under the Editor tab:

Gedit preferences

Alternatively, you can use a terminal to navigate to the directory where you are saving your files and remove the backup files using rm *~.

  • 1
    haha 3 of us answered at the same time XD – RolandiXor Nov 26 '11 at 22:50
  • 1
    @RolandTaylor May the best answer win ;) – Knowledge Cube Nov 26 '11 at 22:54
  • 3
    Guess I do!! :P – Bruno Pereira Nov 26 '11 at 23:13
  • 2
    @BrunoPereira funny - I was thinking autosave saved to the temp file. Good find! – RolandiXor Nov 27 '11 at 19:52

This happens because gedit by default saves backup files.

Open the preferences and disable this option: enter image description here


These are backup copies from the original file. You can delete them if you don't need them.

Most editors have a setting to switch on/off creating those backup files. In gedit (the default editor), you need to switch off "Create a backup copy of files before saving" in the "File saving" section of the "Editor" tab in the "Preferences" dialog.

  • Nice answer, upvoted - I'd not do it though - having a backup of fstab for instance could be nice :) – 23 93 26 35 19 57 3 89 Jun 22 '12 at 5:29
  • Thamks mate it worked ! But now that I know those files are backup, I'm not too keen on disabling them ! :) – upapilot Jun 22 '12 at 5:30

For those interested in disabling 'gedit creating a backup file on save' via a command;

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

I was looking for this command to integrate into my system setup scripts and hadn't found it mentioned anywhere.

  • Hi Thermionix! Can you please give a little bit of explanation as to what this command does? – Alaa Ali Sep 19 '13 at 9:37
  • 1
    This command will change the gedit settings per command line. Assuming the schema org.gnome.gedit.preferences.editor exists. You can find all schemas for gedit by typing: gsettings list-schemas | grep gedit. – Gx1sptDTDa Sep 19 '13 at 13:16
  • Really neat trick mate. Thumbs up – George Kastrinis Sep 23 '13 at 2:34

What are these extra files?

These are backup files as answered by previous answerer.

Is it safe to delete them?

Yes, you can safely delete them, if you are sure that you do not need that particular backup.

Is it possible to stop them from appearing at all?

If you are using gedit text editor (default text editor), it can be stopped with the following way:

  • Open gedit text editor.
  • Go to Edit -> Preferences from menu. (It is on the top panel in Ubuntu now, called global menu)
  • Select Editor tab.
  • Uncheck the option Create a backup copy of files before saving.

    screenshot of Editor options

  • Close the Preferences window

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.