7

I have a directory with images. Suddenly I found out that there's a new image with a new name. The image content is similar to another image in another directory but with a different name. I didn't copy this image to this directory.

Also a directory with the same name as the image suddenly appeared there. I didn't create any of them. When I tried to delete them I got this message "No such file or directory" even though it already existed there. I used the command sudo rm -rf imagename.jpg to delete it but it didn't work.

Can anyone explain why this is happening and how to solve it?

The output of ls -l "large (2).jpg":

-rw------- 1 alaa alaa 2859942 Jun  8 04:01 large (2).jpg

The output of rm "large (2).jpg":

rm: cannot remove ‘large (2).jpg’: No such file or directory

The output of printf %s\\0\\n ./large* | sed -n l

./large (20).jpg\000$
./large (26).jpg\000$
./large (2).jpg\000$
./large (5).jpg\000$

The filesystem is NTFS.

0

2 Answers 2

4

I once posted a pretty in-depth look at NTFS file-streams as related to the linux ntfs-3g driver due to a similar issue on a different question. I remembered it, and - guessing that your problem was also on an NTFS partition - I posted this comment here:

If it's NTFS I suspect this. This can occur if a file's basic permissions are modified as you end up affecting the stream. I think that's what happens. It's complicated - and probably at least a little beyond me. But it happens. Anyway, run chkdsk in Windows.

Apparently, and happily, this has solved your issue.

4
  • I ran chkdsk utility in Win, but to no avail. The files are still there. I created them in Linux, and they contained ":" character, which is prohibited in Windows. What should I do?
    – soshial
    Dec 1, 2015 at 9:44
  • @soshial - delete them. do it from your unix boot first. them reboot and chkdsk.
    – mikeserv
    Dec 1, 2015 at 9:51
  • deleting with rm in linux gives me only "no such file or directory".
    – soshial
    Dec 1, 2015 at 13:43
  • 1
    Be very careful running Microsoft's chkdsk after using NTFS from another OS like Linux. chkdsk will consider all filenames with colons that it finds as invalid, and immediately delete them without warning (rather than altering the filename and preserving the data). See my answer here for more info: unix.stackexchange.com/a/128697/12947 Oct 6, 2017 at 19:26
0

Try:

rm -i large*.jpg

This will ask you whether to delete every matching file. Say "no" for all the files other than this one.

1
  • 1
    same problem : no such file or directory!
    – Alaa
    Jun 23, 2014 at 17:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .