Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

4 Answers

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
share|improve this answer
add comment

“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 its 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.

share|improve this answer
    
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
    
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
add comment

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...

share|improve this answer
    
It would be helpful if you included a link to the 2009 bug report; it might help others track the issue. –  jasonwryan Nov 8 '12 at 9:18
    
Please include in in your answer: the site is a wiki... –  jasonwryan Nov 9 '12 at 19:54
1  
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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