# Making a duplicate of a path in Unix

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?

## migrated from stackoverflow.comMay 31 '11 at 14:57

This question came from our site for professional and enthusiast programmers.

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


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 '11 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. – Seth Robertson May 27 '11 at 0:15