• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 616
  • Last Modified:

linux remove directory

on the command line, I am using rm -Rf directoryname and the directory will not remove, says they are not empty.  Does anyone know another way to remove this?
0
Jack_son_
Asked:
Jack_son_
6 Solutions
 
Kent WSr. Network / Systems AdminCommented:
That command will indeed force removal of a directory and all subdirectories.
There are either immutable files, or a permissions issue.  If you are running this as root, look for immutable files.
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Can you post the exact error message you're getting?
0
 
woolmilkporcCommented:
Could it be that the directory in question is an active mount point or that it contains one or more active mount points (NFS or local, anyway)?

Go to the directory in question and issue "df ." What do you see?

Next, issue "df" alone. Do you see the path to your directory somewhere in a path to a mount point?
0
How do you know if your security is working?

Protecting your business doesn’t have to mean sifting through endless alerts and notifications. With WatchGuard Total Security Suite, you can feel confident that your business is secure, meaning you can get back to the things that have been sitting on your to-do list.

 
TobiasHolmCommented:
try:
sudo rm -rf /path/to/dir

Open in new window

0
 
Jack_son_Author Commented:
the error message is:  

Unable to remove directory dirname:  Directory is not empty
0
 
Kent WSr. Network / Systems AdminCommented:
If you are root, or using su, then there is something other than "regular" files / directories in your target directory.
Look for immutable files, links, mounts, etc. You may have to cd down and remove some directories one at a time until you find the culprit.  Make sure to do an ls -a so you can see hidden files while searching.
0
 
Jan SpringerCommented:
rm -rf /directory

will remove the directory and all files underneath if run as root.  if not root, that the user must have permission to remove all of the files and the directory.
0
 
SandyCommented:
1. go  into directory
2. #ls -lah
3. remove if any hidden directory is there
4. check #df -h to see whether it is being used as mount point for any FS.
5. delete if by using #rm -rf /path/to/dir

TY/SA
0
 
SandyCommented:
if still no luck.. try checking #lsof /path/to/dir

TY/SA
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now