LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 12-24-2017, 07:41 AM   #1
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Rep: Reputation: 11
Post Physical link vs Relative link vs Symbolic link


Hello.
Can anyone tell the different between "Physical", "Relative" and "Symbolic" links? I guess "Symbolic" link is a regular link like "shortcut" in Windows OS and "Physical" link is a link that if you change the link then it applied to real location?


Thank you.
 
Old 12-24-2017, 07:52 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,334
Blog Entries: 3

Rep: Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730
Without dragging M$ into the picture to muddy the water, there are hard links and symbolic links. There are no other kinds.

Hardlinks are where more than one name points to the same file, via its inode, but only files. The cannot span file systems and when the last link to the file is removed, the file is deleted. Symbolic links can be either directories or files, as they are a name not a hard link, and the name is interpreted on the fly. They can span file systems.
See
Code:
man ln
man 2 link
man 2 symlink

Last edited by Turbocapitalist; 12-24-2017 at 07:53 AM.
 
Old 12-24-2017, 08:02 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,976

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
I would suggest you to read the mentioned man pages and/or wiki: hard link symbolic link
 
Old 12-24-2017, 09:59 AM   #4
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,808

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by hack3rcon View Post
Hello.
Can anyone tell the different between "Physical", "Relative" and "Symbolic" links?
The other replies point out that there are only two types of links. As for "relative" links... can you point to a place where these are mentioned? The only way I can think of for a link being referred to as "relative" is when it "points" to a location or file by not using an absolute path, i.e.:
Code:
ln -s ../../some-file link-to-some-file
But the contents of /etc/init.d/rc*.d are full of entries like this and they're always referred to as symbolic links.

Maybe a relative link is a Microsoft-ism?
 
Old 12-24-2017, 12:50 PM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,976

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
the pair of relative is: absolute: a path can be either relative or absolute. But it is not related to links anyhow (so symbolic link can be either relative or absolute, hard link is a hard link to an inode, relative/absolute is out of scope here, not relevant)
 
Old 12-25-2017, 08:09 AM   #6
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Original Poster
Rep: Reputation: 11
Quote:
Originally Posted by Turbocapitalist View Post
Without dragging M$ into the picture to muddy the water, there are hard links and symbolic links. There are no other kinds.

Hardlinks are where more than one name points to the same file, via its inode, but only files. The cannot span file systems and when the last link to the file is removed, the file is deleted. Symbolic links can be either directories or files, as they are a name not a hard link, and the name is interpreted on the fly. They can span file systems.
See
Code:
man ln
man 2 link
man 2 symlink
What does "where more than one name points to the same file" mean?
 
Old 12-25-2017, 08:12 AM   #7
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Original Poster
Rep: Reputation: 11
Quote:
Originally Posted by pan64 View Post
I would suggest you to read the mentioned man pages and/or wiki: hard link symbolic link
Can you show me some examples? Is "Symbolic_link" same to "Shortcut" in Windows OS ?
 
Old 12-25-2017, 08:21 AM   #8
_roman_
Member
 
Registered: Dec 2017
Location: _Austro_Bavaria_
Distribution: gentoo / linux mint
Posts: 433

Rep: Reputation: 29
Did you try to read some documentation ?

And. Do not think or use SPYWARE 95 terms in linux. Spyware 95 refers to the same user interface since windows 3.11, same flaws. linux is not windows. It is something different.

I'm certain there are several tutorials or books which explain that.
I also read different sources until I get the idea behind it.

Quote:
What does "where more than one name points to the same file" mean?
Quote:
Hardlinks are where more than one name points to the same file, via its inode, but only files.
I suggest that you start reading some books or documentations. Introduction to the shell and linux for example!

It is perfectly explained. Same as with other stuff. look up every word which is unknown.

--

I would be careful on using links

best example is

ln -s /usr/src/linux /usr/src/gentoo-sources-x-y

and the device nodes also have these types.

I doubt an user has an use for links
 
Old 12-25-2017, 08:32 AM   #9
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,679
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
The (Windows) NTFS filesystem has a different architecture and therefore a different way of doing some things.

A "symbolic" link is basically "a tiny file with a file-name (and directory path) in it," specially marked to indicate that it is a symlink. When resolving the path, the operating system reads the symlink's contents and textually substitutes its contents.
  • The resulting filename-lookup may not succeed! You can create a symlink to a nonexistent resource, or to one that is subsequently deleted. (This is by design.)
"Hard" links are "multiple directory entries which literally refer to the same underlying file-structure." Their implementation is much more specific to Linux/Unix, because they have to do with the underlying disk architectures. NTFS's architecture and therefore concept is different "by design." Each underlying file-structure object ("inode") contains a count of the number of hard-links which refer to it, so the object won't be deallocated by the filesystem until the last remaining hard-link goes away. (The file's primary directory entry is, if you will, "hard link #1.")

The two types of "links," although similarly-named, are really conceived for entirely parallel purposes. Symlinks are far, far more commonly used.

Some GUIs also implement what they call "shortcuts," and these contain additional information – known to the GUI – which allows the GUI to display an appropriate icon and so-on. But this term is particularly ambiguous in its meaning among different operating systems. ("Link," for some reason, is less so.)

Last edited by sundialsvcs; 12-25-2017 at 08:39 AM.
 
Old 12-25-2017, 09:24 AM   #10
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,783

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
Quote:
Originally Posted by sundialsvcs View Post
(The file's primary directory entry is, if you will, "hard link #1.")
None of a file's hard links is any more "primary" than any other. That's a common misconception. They all have equivalent status. Of course there must have been one link that was created first, but that distinction is lost as soon as another hard link is created, and in fact that first link that a file had might no longer exist.
 
Old 12-25-2017, 09:41 AM   #11
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,646
Blog Entries: 19

Rep: Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480
To understand hard links, you need to understand Unix filesystems. Every Unix file consists of an inode and one or more blocks. The blocks contain the data -- the information stored in the file. The inode contains the metadata -- information about the file: who owns it, how big it is, its access permissions, etc. There is also a set of pointers, direct or indirect, to all the blocks in the file. So once the kernel has the inode, it can read all the data.

One thing inodes do not contain is the filename. Filenames are stored in directories, not inodes. In fact a Unix directory is just a specialised file mapping filenames to inodes. That mapping is called a "hard link". As other posters have pointed out, an inode can legally be hard-linked to more than one filename, and this is a completely symmetrical arrangement. The file is equally accessible via either name. If either is deleted, the file remains accessible via the other. Symbolic links, on the other hand, are asymmetrical: the link refers to the original file by name. If that original file is deleted, the link becomes inoperative.

The content of a file is never deleted as long as there is at least one hard link to it, and that can be very useful. Libraries dynamically linked to a running program and data files currently being accessed acquire extra hard links so that they can't just disappear. The name may disappear from the directory, but programs currently using the data can continue to do so until they exit. That breaks the links and, when the link count has fallen to zero, the data blocks and inode are recycled.
 
1 members found this post helpful.
Old 01-13-2018, 10:38 AM   #12
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Original Poster
Rep: Reputation: 11
If you remove "Hard link" then the real file deleted but it need few space.
If you remove "Symbolic link" then just your shortcut removed.
 
Old 01-13-2018, 10:46 AM   #13
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,976

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
if you remove a hard link, the counter of the links (of that file) will be decreased. The file will only be removed when the counter is equal to zero. Otherwise just the directory entry will be removed, nothing else.
 
Old 01-13-2018, 10:48 AM   #14
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,783

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
Quote:
Originally Posted by hack3rcon View Post
If you remove "Hard link" then the real file deleted but it need few space.
The file is not actually deleted until all hard links have been removed (link count becomes zero) and the file is not currently held open by any process.

I have no idea what you mean by, "but it need few space."
 
  


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
Can I make symbolic link relative?? sk1ds Linux - Newbie 1 10-15-2009 12:38 AM
How to create symbolic link to html file and avoid page link problem? haxpor Linux - General 2 01-29-2008 07:40 AM

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

All times are GMT -5. The time now is 11:45 PM.

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