LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 03-18-2013, 03:45 PM   #1
tech_xavier
LQ Newbie
 
Registered: Mar 2013
Posts: 1

Rep: Reputation: Disabled
Actual location of the unix link


Hi All,

I have a location in my UNIX home directory. I can understand that it is not an actual location and it is a link. So I just want to know which location it is pointing too.

TIA.

Thanks!
Xavier
 
Old 03-18-2013, 03:52 PM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,027

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
not sure i understand the question but if your asking about symbolic links then you can get the file it is pointing to by running this command:
ls -l <filename>
 
Old 03-18-2013, 08:54 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
As schneidz said
Code:
#create test sym link to file t.t
ln -s t.t symlink

# display results
ls -l

-rw-rw-r--. 1 chris chris   68 Mar 15 16:54 t.t
lrwxrwxrwx. 1 chris chris    3 Mar 19 10:52 symlink -> t.t
HTH
http://snipplr.com/view/8490/
 
Old 03-18-2013, 10:41 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 7,151

Rep: Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203
If it helps ... a "symbolic link" is basically a very tiny file containing: a filename. The filesystem knows that it's a link. So, when you refer to the link, Linux reads the filename of the target file from the link, and goes looking for that filename instead. Please notice that it searches for the target file by name, and that it does so when the link is actually referred-to. If the target file can't be found at this time, the attempt fails.

There's another kind of link, called a static link, which these days is so-infrequently used that I don't think we need bother talking about it here.
 
Old 03-19-2013, 08:44 AM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
It called a HARD link, not static.

Every file is represented by an inode, every file that exists has at least ONE hard link. Every entry in a directory of a Linux native filesystem is represented by the pair (inode,name). Second EVERY directory has two entries "." and "..". The "." entry is a hard link to the directory itself (a hard link). The parent directory of that directory ALSO has a link (the directory name). Thus every directory has two hard links.

One very old programming technique uses multiple hard links to a single executable. When executed, the process receives a parameter list... that includes the name it was invoked by. Some programs use this to identify subfunctions of the application. The technique of using hard links for this has been replaced by using symbolic links instead (it makes it more "self-documenting"), but the result is still the same.

One such program that still does this is openssl. If a hard (or symbolic) link is made to /usr/bin/openssl and called "ciphers", then when the openssl application is invoked with the name "ciphers", will actually do the equivalent of the command "openssl ciphers".

The main advantage a hard link has is that it goes directly to the inode - a symbolic link has to reparse the file name from the symbolic link to continue following the directory path. The main DISADVANTAGE of the hard link is that it cannot cross filesystem mounts (each filesystem has its own inode list...). The other disadvantage is a bit of documentation of which file is actually referenced.

A minor disadvantage of symbolic links is that the target of a symbolic link can be deleted, leaving the symbolic link pointing nowhere... and programs that depend on it existing will not report a problem until you try to use the program. A file with multiple hard links is not deleted until the link count goes to 0. So this can't happen with hard links.

It is all a trade off.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
LXer: Unix and Linux Horror Stories And Actual Help LXer Syndicated Linux News 0 12-07-2008 05:50 AM
Location of actual mysql tables and data on RH8 rsleventhal Linux - Server 4 04-01-2008 07:30 AM
Changing a soft link to actual file? jdiemer Linux - Newbie 4 04-05-2006 12:45 PM
how to create link into actual file? elmerliu Linux - Newbie 11 08-15-2004 12:40 PM
how to create a link into actual file? elmerliu Fedora 1 08-14-2004 09:56 AM


All times are GMT -5. The time now is 03:53 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration