Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is annoying feature of Linux.

If I opened a file in a directory and then delete the directory, and copy another directory having the same name to the same place, I can still edit and save the opened file, but it goes to trash! I have made the same mistakes for several times. I carries on editing the opened file and thought it would be saved to the newly copied directory, but it didn't and finally I lost all the editing.

Can I possibly disable this feature?

share|improve this question

migrated from Jun 23 '12 at 12:25

This question came from our site for professional and enthusiast programmers.

Not a programming question. – Oliver Charlesworth Jun 23 '12 at 10:43
This feature is not annoying, and many utilities require it. Linux and most Posix systems (in particular all Unix-like systems) require that behavior. And I don't understand exactly what you mean by deleting a directory. The rmdir(2) syscall would fail if you still have some file entry in the directory. Your editor should detect your situation (emacs does that). You also should learn to use a version control system (like git) for your source code. – Basile Starynkevitch Jun 23 '12 at 10:51
which editor you use to edit files? logically it should throw an error/warning if you save a file in non-existent(deleted) directory. – tuxuday Jun 23 '12 at 10:53
If it goes into the Trash you didn't delete the file, but moved it, and the file is edited at its new location. It's a feature. – Daniel Beck Jun 24 '12 at 11:30

This is functioning as-designed. File descriptors can remain open even after a file is unlinked. The manual page for unlink(2) says:

unlink() deletes a name from the file system...If the name referred to a socket, fifo or device the name for it is removed but processes which have the object open may continue to use it.

share|improve this answer

You must log in to answer this question.