Does anyone knows how to create a sybmbolic "directory" in linux?

I've tried the ln -s directory_to_use directory method, but all it does is just create a "file" that links to directory_to_use, which doesn't work when using FTP.

What I'm looking for is, for example, cPanel's www directory points to public_html as a symbolic link (www itself is a directory), both listing the same contents.

Does anyone know how to create that sort of symbolic link?


Solution 1:

There's only one kind of symbolic link.

The issue you're seeing with FTP is probably that the FTP server is restricted to a subtree of the filesystem (this is called a chroot jail), and a symbolic link pointing outside that subtree won't work. That's by design: the chroot jail is for security, and you mustn't be able to escape the jail by following a symbolic link.

Arrange for all the files you'll ever need to access with FTP to be in the jail. Symbolic links will work as long as they don't try to escape the jail.

(If you are root on the machine, there are ways to make more files accessible within the jail, but I don't recommend fiddling with this if you don't understand all the issues.)

Solution 2:

If you have chroot issues and really do want to make the files accessible in another directory, hard links may be the solution. Keep in mind that by creating hard links in that directory, you are exposing the files you link to (presumably that's okay)

To create a hard-linked copy of directoryA as directoryB/directoryA (assuming directoryB exists already), you would use:

cp -rl directoryA directoryB/

example:

mkdir /var/dupe
cp -rl /var/log /var/dupe/