My Unix vocabulary is failing me. I have 5 billion images in /foo/live/images.

For the purposes of developing a new version of the app I'd like to make /foo/dev/images into a working path without making a copy of the images.

Is this a soft link? What's the right term? What's the command-line syntax to create the link?

2 Answers 2


Dead simple, it's just a symbolic link:

ln -s /foo/live/images /foo/dev/images

Just watch the directory permissions etc. To view the man page (all available options) for the ln command, enter the following at the prompt:

man ln

You can use either symbolic links or hard links (for individual files) assuming they are on the same filesystem.

cd /foo/live; find images -type d -printf "mkdir -vp '/foo/dev/%p'\n" -o -type f -printf "ln -vs '/foo/live/%p' '/foo/dev/%p'\n" | sh

From http://www.commandlinefu.com/commands/view/1776/create-a-symbolic-link-tree-that-shadows-a-directory-structure

Whether you do this or cd /foo/dev; ln -s ../live/images . depends on whether you might write into the images directory.

  • Hard links for "5 billion images" - really? Whilst you're answer is correct, I'd opt for a more canonical example for a *nix novice.
    – Mikaveli
    May 26, 2011 at 23:14
  • @Mikaveli: Sure, you are using a lot of inodes (symlinks) and directory entries/inodes (both), but for some applications/usage patterns you might not be able to use the directory symlink. We didn't get enough information to say which was needed so I provided the option. May 27, 2011 at 0:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.