Take the 2-minute tour ×
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.

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

2 Answers 2

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 –  minhcat_vo Sep 14 '12 at 10:59
    
yeap, I created a link; however, how can I get the content through the link ? thank you . –  minhcat_vo 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

 
discard

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.