March 27th, 2003, 01:52 PM
I'm trying to create a link to a directory. I have looked @ the man pages but no joy.
ln -fh testarea /home/user/testarea
link: testarea: Is a directory
in -fhs testarea /home/user/testarea
that seems to work but when I access the link I run into this error
/home/user/testarea: Too many levels of symbolic links.
Thanks in advance!
March 28th, 2003, 12:39 AM
Wait, you're creating the link _to_ the directory? You've got your arguments backwards. ("ln creates a link to an existing file source_file. If target_file is given, the link has that name ....")
The man page is confusing as hell. "target_file" and "target_directory" should be replaced throughout with "link_name" or some such.
Regarding the first error you were getting, directories cannot be hard linked, only symbolically linked.
March 28th, 2003, 01:14 AM
Thank you for your reply.
So how would I go about creating a link to a directory?
March 28th, 2003, 11:06 AM
One would create a link to a directory like this :
ln -s /path/to/realdir [name_of_link]
The name of the link is optional; without it the link name will be the same as the "source" file or directory. In this case, "realdir".
So, in your case, the following should be sufficient (if I am guessing your intentions correctly) :
ln -s /home/user/testarea
... which would leave you with a link in /usr/local/www/data/ that looks like a subdirectory named testarea and points to the actual subdirectory /home/user/testarea .
March 28th, 2003, 01:01 PM
September 27th, 2005, 06:22 AM
Only 2 and half years late
But still a solution.
I wanted the directory linking from a location to a users ftp home folder, but using symlink the links were not available in ftp, whether this was the ftp server hidding them or not I'm not sure.
But found a nice method using the mount command, this allowed me to create a link between the destination and was also available in FTP clients.
mount --bind <DESTINATION> <NEW FOLDER>
This is only available till next restart, to have the mounted directory available after restart, add the following line to your /etc/fstab file
<DESTINATION> <NEW FOLDER> none bind
Last edited by pgudge; September 27th, 2005 at 11:44 AM.
Reason: added fstab info