Ask Different is a question and answer site for power users of Apple hardware and software. 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

In terminal, I have made a symbol link like following:

ln -s ../../../../ jni/prod

It symbol links prod directory (which is 4 levels up from current location) to jni/prod .

I'd like to emphasize that it symbol links a directory NOT a file.

Now, I want to remove this symlink, how to do it?

share|improve this question
What did you try already? – patrix Nov 6 '13 at 15:09
And more importantly, if you don't describe what you "don't get" then people have to guess. Hopefully my guess as to what you don't get about symlinks was correct. – bmike Nov 6 '13 at 15:21
up vote 2 down vote accepted

If you find yourself confused about where a file really exists, cd to the directory you expect and use rm -i and refrain from adding any path - delete the file in the current directory. Also, in unix, everything is a file - including a directory. You do have saving grace that trying to delete a file that looks like a directory will pause unless you are recursively deleting files.

Worst case, you could use ls -lai to inspect the inode numbers to be sure a file is really symlinked and not hard linked.

If that doesn't help, make a temp directory and play with links:

touch foo
ln foo bar       # hard link
ln -s foo baz    # sym link
ls -lai
rm foo
ls -lai

At this point, you have the hard link file bar left and a sym link to the missing "foo" file. Since in your case, the link is in a different directory than the target, you shouldn't have too much problem deleting the item you wish.

share|improve this answer

A symbolic link is a file even if the link is to a directory. So if you simply did an rm that will get rid of the link:

rm jni/prod
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.