Server Fault is a question and answer site for system and network administrators. 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 wondering if anyone knows of a nice way to partially duplicate (hard link) files between two directory structures?

My current fall back is a script invoked by cron.

As background:

I ask since I have two groups who both need to access a body of files in a directory structure served via HTTP using Tomcat. A privileged group may access all the files and a less privileged group may only access a "public" subset. These sets are not aligned to particular directories but the different class of file can be identified by their naming convention (but not extension).

Therefore my current idea is to serve two separate directories, one containing only private (possibly password protected) and the other containing public. Then to run some periodic process whereby I create hardlinks from the public files so they appear in the private directories for the convienence of the privileged users. I choose to link in that direction since it's more important that the file is available immediately for the unprivileged users. (priv = admin, unpriv = regular user)

I hope that makes sense. I'll try to clarify if anyone has any questions.

share|improve this question
up vote 1 down vote accepted

I would use symbolic links.

You could use this Bash script:

ln -s $1 $2/$(basename $1)

with something like these two commands:

find unpriv_criteria -exec ./linkscript {} /unpriv/dir \; 
find priv_criteria -exec ./linkscript {} /priv/dir \;
share|improve this answer
Why do you recommend soft links? I was prefering hardlinks since I won't have to configure Tomcat to follow soft links. In addition it would afford me the luxury of being able to remove files from the public directory without removing it from the private directory. Hope that makes sense? – Tom Duckering Jan 14 '10 at 6:43
Here is a discussion of hard and symbolic links:… – Dennis Williamson Jan 14 '10 at 9:18
Thanks for the link. I know the difference and the pros/cons but was wondering why you explicitly recommended using soft links. – Tom Duckering Jan 14 '10 at 9:27

Something like what Dennis proposed would work in a cron job or similar.

If this were linux, I would point you at inotify which would allow you to eliminate the cron job and latency from hardlinks reflecting the original directory.

This doesn't appear to exist under Solaris, however.

If the hardlinks are not too critical, a cron job will probably do just fine.

share|improve this answer
inotify for Solaris 11:…. – unixhacker2010 Aug 30 '13 at 6:22

Your Answer


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.