Server Fault is a question and answer site for system and network administrators. 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

I want to remove all files and folders in folder /home/user I'm using command

rm -rf /home/user/*

without success, next I tried:

cd /home/user;rm -rf *

Which gives the following output

rm: cannot lstat `*': No such file or directory

How do I solve that? If I'm deleting file one by one, it works, but with "*" it does not.

share|improve this question
Why isn't the first command working? What error are you getting? – Bart De Vos Apr 7 '11 at 9:09
it does nothing, files still in place – user77473 Apr 7 '11 at 9:10

Does your user have read access to the files you want to remove? What are the filenames like? If they begin with a . they may not be picked up by the *.

To delete files starting with . in the current directory, you can use the old trick of find piped to xargs:

find . -name '.*' -maxdepth 1 -type f | xargs rm

Try first without the | xargs rm to see if the files returned by find match what you expect, then run it again with the pipe.

If you want to also look for files recursively, just take the -maxdepth 1 out of the command.

share|improve this answer
they are starting with ".". how delete files starting with "."? – user77473 Apr 7 '11 at 9:12
Advice: Do NOT try rm -rf .*. Depending on your config, this may match "..", ie upwards in the directory structure. – carlpett Apr 7 '11 at 9:14
solution, i don`t know if is it kind of right, but it works:ls -a | xargs rm -rf – user77473 Apr 7 '11 at 9:26
For the same reason, if you use that solution, you might want to make that ls -A | xargs rm -rf (captial A is "all files, except '.' and '..'). – carlpett Apr 7 '11 at 9:53

What about:

find /home/user -delete

But be careful - read the man page for find first! Or train a bit in a particular directory.

share|improve this answer

I just use rm -rf /home/user.

share|improve this answer

Your Answer


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.