unix Links

I was not clear about unix 'Links' concept. How same file has different name in different directory. It seems confusing to me. I wonder what are the practical uses, advantages, disadvantages, applications of links. What other operating system has similar concept? Please advise.
LVL 7
gudii9Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oleggoldCommented:
You can see them as shortcuts in Windows
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
oleggoldCommented:
Advantages are numerous but first You need to diff. between softlinks which are exactly like shortcuts and hardlinks that basically pointers to the real file and will behave the same way the file'd be .First great advantage of all links - they save space on Your HDD  
0
oleggoldCommented:
2nd + :  they eliminate duplicate copies of the same program , though better solution is add the file (if executable )to  $PATH variable
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

omarfaridCommented:
There are two types of links: hardlink and softlink

Hardlink is simply another name for the same file (not a copy). The advantages are:

- You can have links to the same file with different names
- You can have links for the same file from different directories
- You can safe files from accidental delete
- Some programs run differently when called by different name (e.g. vi and ed)

hard links will work within the same file system only and cannot work across file systems
hard links cannot be used for directories

The softlinks will work across file systems and can point to a directory

soft links will not protect you against original file deletion and will not work if the original file name is changed

0
ManjitkCommented:
To make links between files you need to use ln command. A symbolic link (also known as a soft link or symlink) consists of a special type of file that serves as a reference to another file or directory. Unix/Linux like operating systems often uses symbolic links.

Two types of Links:
1)symbolic links: Refer to a symbolic path indicating the abstract location of another file
2)hard links : Refer to the specific location of physical data.

To create a symbolic link in Unix or Linux, at the shell prompt, enter the following command:
ln -s {target-filename} {symbolic-filename}

A hard link to a file is indistinguishable from the original directory entry; any changes to a file are effectively independent of the name used to reference the file. Hard links may not normally refer to directories and may not span file systems.

ln {source} {link}
(source:- is an existing file.
link :- is the file to create (a hard link)).

Hard Links Limitations:-
There are some issues with hard links that can sometimes make them unsuitable. First of all, because the link is identical to the thing it points to, it becomes difficult to give a command such as "list all the contents of this directory recursively but ignore any links". Most modern operating systems don't allow hard links on directories to prevent endless recursion. Another drawback of hard links is that they have to be located within the same file system, and most large systems today consist of multiple file systems.


0
dadhebCommented:
One common scenario where symbolic or softlinks are used is version control. For example, you can have a symbolic link called latest, working to the latest or working version of the file.

This way you can easily change versions by changing its link.
0
ozoCommented:
grep, fgrep and egrep are often links to the same binary, which changes its behaviour depending on the name with which it was invoked.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.