LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-30-2013, 12:22 PM   #1
ulkoma
Member
 
Registered: Feb 2012
Distribution: CentOS
Posts: 69

Rep: Reputation: Disabled
What are symbolic link good for?


Why do we need them? both types?

I familiar with creating them ..etc but why do we need them???

Regards
 
Old 07-30-2013, 12:35 PM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
In simple words, they are like shortcuts. Suppose you've some application installed somewhere and you everytime need to follow it's full path to launch it, so in order to avoid using full path, you create a symbolic link of it on your desktop for ease of access. Similarly, you create symlink to a file which is deep inside the directory tree, so you create a symlink in your home folder or on desktop to easily access it. Also, whatever changes you make in symlink original file, gets reflected in other one.
 
Old 07-30-2013, 12:39 PM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Seems the OP is asking why you need "Soft links" and "Hard links"

Which is explained in great detail on websites that can be found through Google.

https://www.google.com/search?q=hard+links+soft+links

Turned up 13,000 results if you'd like to research it further.
 
Old 07-30-2013, 12:45 PM   #4
ulkoma
Member
 
Registered: Feb 2012
Distribution: CentOS
Posts: 69

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by shivaa View Post
In simple words, they are like shortcuts. Suppose you've some application installed somewhere and you everytime need to follow it's full path to launch it, so in order to avoid using full path, you create a symbolic link of it on your desktop for ease of access. Similarly, you create symlink to a file which is deep inside the directory tree, so you create a symlink in your home folder or on desktop to easily access it. Also, whatever changes you make in symlink original file, gets reflected in other one.
I forgot to add "apart from the obvious use of it in MSWindows" to my question
 
Old 07-30-2013, 12:59 PM   #5
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
If you are familiar with creating them and ... etc then you know what they are for and why they are needed. And if you DO NOT know this, then you should research the subject on the internet. It is not difficult at all to find thousands of examples and howtos and documentation on the subject.

Doing the legwork yourself will ensure a much greater understanding.

Also:

http://www.linuxquestions.org/questi...ymlink-799528/
http://www.linuxquestions.org/questi...-links-531463/

Don't be afraid to search LQ before posting a question.

Last edited by szboardstretcher; 07-30-2013 at 01:02 PM.
 
Old 07-30-2013, 01:00 PM   #6
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Assuming you know why you want links in the first place, and are only asking regarding the differences between hard links and symbolic links, for one, symbolic links can cross filesystems, hard links can't. Symbolic links can be created before the file they use as their target even exists. You can't create a hard link to a non-existant file. With a hard link, if you delete the original file, you can still access its contents via the hard link. With a symbolic link, once the original file has been deleted, you cannot access the original files contents anymore. I use symbolic links far more than hard links personally.
 
Old 07-30-2013, 01:06 PM   #7
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
If you are indeed asking why you want links, any link type, in the first place, think of it this way:

If you want to show a friend in a different state what your house looks like, do you go up there and build a duplicate of your house (a "copy")? Or do you sent them a photograph of your existing house (a "link" - well not exactly, but for purposes of this discussion it's close enough). You don't want the resource usage (cost) of creating a duplicate "copy" of your house, you just want to "refer" to the existing house.
 
Old 08-02-2013, 01:23 PM   #8
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Quote:
Originally Posted by haertig View Post
With a hard link, if you delete the original file, you can still access its contents via the hard link.
Well, yes and no. Every regular file name you see on your system is actually a hard link. The name that you see on your file tree is really just a textual representation of an inode, a human-readable "link" to the actual location of the file on the disk.

So when you create a hard link to an existing file, you're actually, and literally, giving it another name, i.e. every single one of a file's hard links literally IS that file (which is why they all have to be on the same partition). If you remove one hard link, the file will still exist under its other hard links, if any. Only when you remove the last hard link do you actually delete the file (i.e. you unlink the inode completely and make that space available for new use).


A soft link, on the other hand, is a completely different beast. It's just a special kind of file that, when accessed, tells the system to jump to another location on the file tree and continue the processing there. Unlike hard links, they can cross partition boundaries, and the file location it's pointing to doesn't have to actually exist.
 
Old 08-02-2013, 02:03 PM   #9
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Quote:
Originally Posted by David the H. View Post
Well, yes and no.
What you just said is exactly what I said. Or tried to say. Maybe I wasn't clear in the way I stated things.
 
Old 08-02-2013, 04:13 PM   #10
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Don't sweat it. You basically had it right. But yeah, it could give the wrong impression, so I just thought I'd clarify it a bit more.
 
Old 08-02-2013, 06:06 PM   #11
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
One thing not mentioned is that hard links are only valid within a single filesystem. Softlinks/symbolic links have the path to the file, so that the link can point to a file not in the same filesystem as the link itself.

Another thing not mentioned (though this is true for both hard and soft links), is that it is possible to use the name of an executable as a parameter. This has been done for things requiring a root password -- the utility that asks for the password has a symbolic name pointing to it that identifies the function. After the utility gets a proper password, it then looks up the name it was invoked by in its table to identify the specific program to run.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Can I make a symbolic link that is dynamic link->$HOME/file? croog Linux - General 4 10-14-2012 07:55 PM
Symbolic link not allowed or link target not accessible rheluser Linux - Server 3 09-04-2012 10:22 AM
symbolic link not allowed or link target not accessible paullaubscher Linux - Newbie 4 03-10-2010 06:47 AM
How to create symbolic link to html file and avoid page link problem? haxpor Linux - General 2 01-29-2008 07:40 AM
Symbolic link? jasone Linux - Newbie 4 05-06-2005 07:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration