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


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

  • 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 – daisy 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.

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.