PDA

View Full Version : Linux - What is a (ln) link? Can I use it to replicate a dir in two places?


Bawy
04-26-2003, 12:53 AM
I need the file system equivelent of a database view (you MySQL/Access people may have never heard of a view, keep reading NEwayz.)

I have two domains with different sites running on the same server, they have gaphic elements in common that I would like to consolidate into one directory.

I do not want to reveal the two sites share content in the HTML source code, so simply making fully-qualified URLs to the other site is not an option.

I do not want to leave the directory below both roots and pass the images through a PHP script, the server is pretty stressed as it is, more CPU work is not a good idea in this case.

Ideally I could create a hypothetical directory that is always identicle to the other. So site1.com/images is the same as site2.com/images, but only site1.com/images is a real directory. Is that what a link is in Linux? The ln comand so I have read?

It would be simpler (politically in this company) to not involve the sys admin who did not give me access to the httpd.conf, there goes virtual directories... Or can you make them in .htaccess? I do have ssh access, just the rights to the good stuff are left to SU which I am not given rights to.

Bawy
04-26-2003, 09:45 PM
Been experimenting with Linux, I think this will do it, someone tell me if there are side-effects though?

site1/images contains the images, site2 does not have any directory called images:

ln -sn site1/images site2/images

Spookster
04-26-2003, 10:32 PM
Originally posted by Bawy
Been experimenting with Linux

Either famous last words of a Sysadmin or a Sysadmins' worst nightmare of a user. :D

Bawy
04-27-2003, 04:20 AM
Cute...

Any idea if I am on the right track though?

jkd
04-27-2003, 05:57 AM
I was going to suggest using "ln -s" before you replied with your own snippet, and since you included that same parameter, I'm assuming I know more about Linux than I feel confident posting about. :)

As far as I know, a soft link to the image directory is exactly what you want, and exactly what you're doing with that command.

Bawy
04-27-2003, 12:12 PM
Cool! Tried it, works perfectly, regained 60mb of server space...

Only time the link does not act like the real directory is in WS_FTP which does not seem to know what to do with it...

bcarl314
04-28-2003, 07:52 PM
Weird, I've got a server with soft links and when I connect via FTP I go right to the linked directory. ??? Oh well, one thing I would suggest on ln or any other command in linux / unix is to check the man page.

ex:

man ln

will give you all sorts of good info on the ln command.