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.

I know we can do that for files. What about directories?

It seems that cpanel uses that a lot.

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

Most filesystem do not support hard links on directories. However, you can symlink directories.

You can bind mount a directory in Linux, which functions similar to a hard link from a user's perspective. Here is an example:

mount --bind /usr /home/user/foo

This is commonly used for chroot environments, since a symlink is relative the chroot's /, a bind mount can provide access to locations outside of the chroot.

share|improve this answer
    
Make that "no sane filesystem handles directory hardlinks" –  vonbrand Jan 23 '13 at 20:47
add comment

In centos, I have tried soft link between directories by

ln -s path/to/actual/folder name/of/link/folder

ls -ld link/name

Will show you if you have successfully created link.

share|improve this answer
add comment

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.