Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com May 31 '11 at 14:57

2 Answers

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
share|improve this answer
Thank you very much! – jerrygarciuh May 27 '11 at 0:50

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.

share|improve this answer
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
Thank you very much! – jerrygarciuh May 27 '11 at 0:50
+1 for providing the alternative. :) – Mikaveli May 27 '11 at 8:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.