Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This is probably very simple, but I really can't get it to work. I have an old directory with a symlink in it. I need to delete the directory, but it says it is not empty when I try:

rm -f dirname  

(I have also tried -r, and -rf)

I get: "usage: rmdir directory-name"

So then I try rmdir -f dirname, but I get the same response. I am a newb to the command line and would really appreciate if someone could help.

share|improve this question
2  
What OS? You are claiming you get a rmdir message by running rm. What travesty has been inflicted on your rm? Try type rm. –  jw013 Jun 19 '12 at 1:32
    
As @jw013 says, an rmdir error from rm proper is odd. Try /bin/rm -r dirname. –  Kevin Jun 19 '12 at 1:33
3  
Everyone, OP is trying to delete from inside a ftp client, not the Unix command shell. I tagged the question with osx and ftp and edited the question header, but the edit has to be approved first before it shows. –  Levon Jun 19 '12 at 2:41

4 Answers 4

Before you can remove the directory, you need to remove the file that's in it.

rm testing/name_of_the_symbolic_link
rmdir testing

If there are many files, you need to remove them all.

If you want the convenience of familiar command line or GUI file manipulation tools to manipulate files over FTP, you can mount the FTP directory as a filesystem. Some OSes have this feature integrated in their GUI (for example, Ubuntu does as far as I recall); I don't know about OSX. You can mount the FTP directory on the command line using CurlFtpFS.

mkdir ~/mnt
curlftpfs ftp://ftp.example.com/remote/path ~/mnt
rm -r ~/mnt/testing
fusermount -u ~/mnt
share|improve this answer

Try this command:

rmdir -f dirname
share|improve this answer
    
Explanation necessary, especially with so many better ideas right there. Why might this work when others didn't/don't? –  killermist Jul 8 '12 at 17:17

To find any lagging files under testing/ and get rid of them.

find testing/ -type f -exec rm -f {} \;

Sometimes files or symlinks can get created that contain special characters and those can stymie our attempts to remove them using common tools.

Then, do the same for directories:

find testing/ -type d -exec rm -f {} \;

After that, testing/ should be empty and you should be able to rmdir it.

share|improve this answer
    
Tim, I am using Mac OSX terminal to connect to ftp to my Dreamhost server. The find command is not available. Again, I plead ignorance on the subject matter. –  user19993 Jun 19 '12 at 2:35
1  
ah, you may want to try a graphical ftp client like Transmit (panic.com/transmit). The GUI clients often have implementations of advanced features that are difficult in the old CLI ftp client. –  Tim Kennedy Jun 19 '12 at 2:42
    
I have transmit, but when I try to delete the folder or file i get an error. That is why I resulted to the command line. –  user19993 Jun 19 '12 at 2:46
1  
Dreamhost has shell access, via SSH, if you enable it for your account. That would possibly give you better control over that directory. (wiki.dreamhost.com/Enabling_Shell_Access) –  Tim Kennedy Jun 19 '12 at 15:20

Two things come to mind:

(1) did you check the directory to make sure it's really empty? Did you look for hidden files with

ls -a?

hidden files: files with a name that start with . and don't show with regular ls. If you do find some, delete them and try your command again.

(2) try rm -fR dirname

share|improve this answer
    
I'm on a Mac using terminal to ftp. I tried 1 & 2. There are no hidden files. When I try 2, I still get "usage: rmdir directory-name" –  user19993 Jun 19 '12 at 1:38
    
@user19993 re "on a Mac using terminal to ftp" .. is this osx, and just to be sure, you are trying to delete the directory not via ftp, but on your Mac in one of your directories, right? –  Levon Jun 19 '12 at 1:42
    
I am on a mac OSX. I have connected to my ftp via terminal - in an attempt to delete this directory because I cant seem to do it via FTP programs or web interface. –  user19993 Jun 19 '12 at 1:43
1  
@user19993 Ok, thanks that's helpful, I added a OSX tag to your question. I am still a bit unclear about how/where you are trying to delete the file. What is your prompt, is it a regular terminal prompt or something like ftp>? –  Levon Jun 19 '12 at 1:46
    
I am connected to my Dreamhost ftp account via terminal for Mac. I have a directory in this account that used to hold a wordpress install. I deleted the files within, but the wp-content folder is still there with a symbolic link inside. I want to remove this entire directory, but I cant. I assume the best (most powerful) way to do this was via command line. However, I cant seem to get the force remove commands to work. I hope this helps - again I'm pretty new to this so sorry if I'm missing something here. And yes the prompt is ftp> –  user19993 Jun 19 '12 at 1:52

Your Answer

 
discard

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.