Super User is a question and answer site for computer enthusiasts and power users. 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'm setting up the document root of my web server to point to a folder elsewhere on the disk. Should I be using a hard link, or a soft link, with the ln command?

Also, I'm having trouble getting the symbolic link pointing to a directory. I get the message ln: /Users/me/directory/: Is a directory when I try to set up the link.

share|improve this question
Hard linked directories are most often not supported. Are you sure you are trying to ln -s the directory? – choroba Feb 9 '12 at 23:15
It's interesting that you refer to linux; I didn't know of any linux distribution with /Users/ as the folder for home directories; usually it's /home/. However, Mac OS X typically uses /Users/ to store the user's home directory. – Karolos Feb 9 '12 at 23:16
I'm on Mac OS X, but since I figured it would be best to ask the Linux community this question since the terminal has the same exact command. Tag added – babonk Feb 9 '12 at 23:17
up vote 3 down vote accepted

A soft link is enough for your purpose. You simply need to omit the trailing slash, i.e.

ln -s ~/me
share|improve this answer
Thanks. Why is a soft link better for this purpose? Trying to understand. – babonk Feb 9 '12 at 23:16
The soft link points to the path of a file in the directory tree; the hard link points to the inode, i.e. the actually location of the data. As choroba mentioned, hard links are not often supported for directories. Also, hard links are linked to one file system, e.g. you couldn't make a hard link to a network file system. – Karolos Feb 9 '12 at 23:19
One advantage of hard links, though, is that, since you point to the data, the link is valid when you move the file being pointed to. In the case of a symlink (short for symbolic link), the link is just broken. – Karolos Feb 9 '12 at 23:21
@babonk: For more reading, you can start will all parts of… – Karolos Feb 9 '12 at 23:23
@babonk: To clear things up a tiny bit: "symbolic" and "soft" links are the same. Hard links are different. And by default, ln creates hard links. – grawity Feb 10 '12 at 0:36

You must log in to answer this question.

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