-2

I'm trying to remove directory from my external hard drive that I mounted to the file system. I'm using the rm command with the flag rf but I got the following error:

Directory not empty

Apart from the rm command, I tried to remove file which is located in that directory recursively by entering the directory, but I got this strange error:

 No such file or directory

This is strange because the directory and the file which are located in the directory that I want to remove exist.

d-cubed
  • 1,034
  • 5
  • 30
  • 58
harianja
  • 63
  • 2
  • 8

1 Answers1

3

This question probably belongs to Superusers and not StackOverflow, but try to see what is in the directory by listing hidden files, like;

$ ls -la directoryname

In Linux/Unix all files which starts with a . (dot) are considered hidden files

Another possibility is that you don't have permissions to remove the content -- the -f in rm -rf will cause those files you cannot remove due to permission issues to be ignored, so you can also try to issue the rm without the f option, like

rm -r directoryname
Community
  • 1
  • 1
Soren
  • 14,402
  • 4
  • 41
  • 67
  • i used the rm -r directoryname but i still got the same error – harianja Apr 23 '14 at 17:23
  • you are most likely dealing with a NFS mounted directory which is failing -- is this your personal machine or a company owned machine? – Soren Apr 23 '14 at 17:26
  • Also try to do a `ls -lRa directoryname` -- the R option will recursively list all files in the directory so that you can see if anything and what is left – Soren Apr 23 '14 at 17:27
  • this is my own machine and what is NFS mounted directory? – harianja Apr 23 '14 at 17:28
  • i have tried to used ls -lRa command,and there are several folder contain in that folder that i want to delete.now what next to do? – harianja Apr 23 '14 at 17:33
  • That is a question to ask on superuser.com – Soren Apr 23 '14 at 17:34