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

When I ls -ls on my folder I get this now:

27216 -rw-r--r--   1 qat users 27865731 2012-03-16 09:13 deploy

But it was a directory, is there a quick way to convert it back?

share|improve this question

migrated from Mar 16 '12 at 14:27

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

No, there sure is no quick way to "convert it back". I can't imagine how this happened in the first place, probably you deleted the directory and placed a file there. – Niklas B. Mar 16 '12 at 14:25
Using the same tiny magnet that was used to bypass all the filesystem safety check, you can flip the bit back. – Simon Richter Mar 16 '12 at 14:33

No, there's no quick way to convert it back.

I share the opinion of one of the commenters that you probably inadvertently removed the directory and replaced it with a file. Assuming the file size didn't change, 27MB would be a gigantic directory, containing hundreds of thousands of files. In many years of doing Unix admin work, I've only seen one directory with over 100,000 files in it, so I'm doubtful that you had a directory that large. Take a look at the files contents and see if it looks familiar; odds are good that the file contains logging output from some process or the other.

Assuming you're not mistaken and a directory was silently converted to a regular file, this is very bad news for your system. A number of things could be wrong, and I would not trust this system again until I figured out what component (disk, disk controller, RAM, filesystem code) is failing.

share|improve this answer
Good explanation. My advise would be to use file deploy to check the file type. – Niklas B. Mar 16 '12 at 23:34

This was happening to me running arch-linux because my /home directory was mounted on a usb hard drive and it was autosuspending. So I had urxvt and tmux open in the /home/user directory and was logged into X.

I went away from my screen for an hour and came back and typed vim into the urxvt bash shell. Since the drives were suspended they first had to wake up so it took about 5-10 seconds for vim to load. It doesn't have to be vim for this to happen but when I went back to bash some of my directories like /home/user/tmp and /home/user/.vim had been converted from directories to files.

The fix for me was to reboot into level 3 as root and unmount /home, then running an fsck -f on the hard drive, then I rebooted and the files had been converted back into directories and none of my files were lost or corrupted.

Then I disabled usb autosuspend to keep it from happening again.

share|improve this answer

They suggest on to remove the file and create the directory:

rm filename
mkdir filename

But on my corrupted? NTFS 3G external drive, I just got:

rm: filename: No such file or directory
mkdir: filename: File exists

So am not sure what the solution if any would be.

share|improve this answer
You're not answering the users question. If you have a question, please post a new one for people to answer. Cheers. – Mogget Oct 5 '15 at 23:51

You must log in to answer this question.