Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 get stuck to create a shell script for a new link something like that

link linkPathName orginalPathName

I want to create a link between a new link and original path; however, both can access together. For example, if orignialPathName was a directory, it also creates a link to access all files and folders for a new link

share|improve this question
up vote 3 down vote accepted

The correct command in use was:

ln -s orginalPathName linkPathName

To view the contents of a directory, use something like:

ls linkPathName/

For a non-directory, use command like this:

cat linkPathName

share|improve this answer
thank you @warlOck a lot – cat_minhv0 Sep 14 '12 at 10:59
yeap, I created a link; however, how can I get the content through the link ? thank you . – cat_minhv0 Sep 14 '12 at 11:32
@minhcat_vo updated answer with an example – warl0ck Sep 14 '12 at 13:17

Keep in mind, that there are two types of links:

  • symbolic ( soft ) link. it is just reference to a file or directory system wide ( more )
    To create it use

    ln -s /path/to/original/file /path/to/link

  • hard link. it is a new entry in file system, that referers to the same file (with dir it doesn't work) inside one filesystem only ( more )
    To create it use

    ln /path/to/original/file /path/to/link

The difference and advantages of each type you can find in the wikipedia.

share|improve this answer

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.