3

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

2 Answers 2

4

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

2
  • yeap, I created a link; however, how can I get the content through the link ? thank you .
    – cat916
    Commented Sep 14, 2012 at 11:32
  • @minhcat_vo updated answer with an example
    – daisy
    Commented Sep 14, 2012 at 13:17
4

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .