Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-18-2013, 02:45 PM   #1
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.


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

Rep: Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876
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, 07:54 PM   #3
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
As schneidz said
#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
Old 03-18-2013, 09:41 PM   #4
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,326
Blog Entries: 4

Rep: Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842
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, 07:44 AM   #5
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,702

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
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.


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 04:50 AM
Location of actual mysql tables and data on RH8 rsleventhal Linux - Server 4 04-01-2008 06:30 AM
Changing a soft link to actual file? jdiemer Linux - Newbie 4 04-05-2006 11:45 AM
how to create link into actual file? elmerliu Linux - Newbie 11 08-15-2004 11:40 AM
how to create a link into actual file? elmerliu Fedora 1 08-14-2004 08:56 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:46 AM.

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