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?

  • 1
    What did you try already?
    – nohillside
    Nov 6, 2013 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, 2013 at 15:21

2 Answers 2


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.


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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .