I have a text file that I can change using other applications (for example openoffice). But when I try to change and save it using gedit, I am getting error from gedit:

Could not save the file /media/sf_Ubuntu/BuildNotes.txt.
Unexpected error: Error renaming temporary file: Text file busy

the permission of BuildNotes.txt is as follow:

-rwxrwx--- 1 root vboxsf  839 2012-10-26 12:08 BuildNotes.txt

and user id is:

m@m-Linux:/media/sf_Ubuntu$ id
uid=1000(m) gid=1000(m) groups=4(adm),20(dialout),24(cdrom),46(plugdev),105(lpadmin),119(admin),122(sambashare),1000(m),1001(vboxsf)

What is the problem and how I can fix it?

  • and vim works fine... – Leon Sep 27 at 3:15

This problem has been reported since 2009 (google for 'gedit virtualbox'). It is awful that there's no fix for it yet. Neither VirtualBox nor Gedit developers are willing to take responsibility for it, and instead are content to point fingers at one another for over three years.

You can set your editor preferences to 'Create a backup' then save twice. Incredibly painful, but it works.

Some other editors won't report the problem. However, when I tested Kate and nano, for example, those just silently deleted the file on every other save. That's even worse than the gedit situation...


“Text file busy” can be confusing here: it isn't actually about text files, but about executables. Executables are called text files because… hum, actually, I don't know why.

What the message really means is “this file is locked by another program that is using it and can't let it be modified under its nose, so you can't write to it.” It is quite unusual to see this message for a text file: unix systems generally frown on mandatory locks on files, and there is no facility for applications to lock out others from modifying a file. (Unix has advisory locks: they can be used to synchronize concurrent accesses to a file by cooperating programs.) The most common circumstance when you'll see “text file busy” (ETXTBUSY) is if you try to modify an executable that's running: the kernel locks it. Another possibility is a disk image that is mounted, again locked by the kernel.

In your case, given the location of the file /media/sf_Ubuntu and the ownership to the group vboxsf, my guess is that the file, which is on a VirtualBox file sharing filesystem, is locked in the host operating system. Presumably the host is a Windows machine and you also have the file open in an editor there. You'll need to close the file on the host before you can save in the editor in the VM.

  • 4
    thanks. I am %100 sure that the file is not oprn in windows and also no other application is using it. I can open it using OpenOffice and hence I am sure that it is not opened by other applications. It is only gedit that can not save it. – user654019 Oct 28 '12 at 13:59
  • 2
    I am having the same issue. every program in guest os works great but gedit, something is up. – GlassGhost Apr 22 '13 at 23:44

Check with lsof if the file is open by another application

lsof /media/sf_Ubuntu/BuildNotes.txt

Or use fuser:

fuser -km /media/sf_Ubuntu/BuildNotes.txt

The problem is fundamentally with glib and the way it saves to a temporary file, then renames. The bug has been recorded as: https://bugzilla.gnome.org/show_bug.cgi?id=656225


What fixed it for me (still a bit annoying but works), and is applicable to gedit, is to:

edit - preferences - editor Put a check on "Create backup copy"

When saving from now on, save the file once, ignore the error, save again. works every time.

  • In 2019, this error still occurs. This workaround works. – David Apr 11 at 13:28

using linux terminal, try editing the file using vi file_name and save it. p.s I could not find another solution for this issue. vi worked

protected by Anthon Sep 26 '17 at 13:28

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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