Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
If I understand this correctly, the "1" after the permissions section and before the ownership section shows that there is one link attached to the axis.jar file. If this is correct how can I find the location of the link that points to the axis.jar file? In other words is there a way to find all links for a given file?
This "1" is the number of hardlinks, not symlinks. You need to understand the concepts of inodes, hardlinks and symlinks. Take a look at this for example.
In other words is there a way to find all links for a given file?
Only thing comes up is bruteforce FS traversal. Crude example follows. Finish off by narrowing down search area, apply regex or iname search, or use a grep pipe.
Code:
find /some/dir -type l | while read f; do i=(`stat -c "%N" "${f}"`)
case "${i[2]:1:3}" in ../*) prefix=${f%/*};; esac echo "${f//*\//}: \
`readlink -f "${prefix}/${i[2]:1:$[${#i[2]}-2]}"`"; done
ls -li will give you the files inode, which you then can use with find / -inum <number>
I have a file in /etc with inode number 88216 and at least two relative symlinks, but "find /etc -inum 88216" doesn't show a darn thing?
Indeed. Hardlinks share inodes, symlinks don't use inodes at all. That's why hardlinks cannot cross filesystem boundaries and symlinks can.
In short, think of symlinks as small "text" files that only hold the path to where the symlinks point. If the linked target is gone, then the link points to nothing. The "path" stored can be anywhere, in any filesystem.
When a file is created on disk (ie "touch"), it gets one hardlink in the directory where you created the file. This hardlink is nothing else than an entry in the directory's table of contents that lists both the filename and the inode of the file on disk.
When another hardlink is created (so another entry in some directory's table of contents, with a reference to the same inode/physical file), the inode reference is "shared" between both directories.
When any hardlink is deleted, the number of links (viewable by ls) decreases. If it reaches 0, then the file is "erased" from disk and no longer accessible.
find /path/to/dir -type l -printf "%p\t%l\n"
Shouldn't that be %h/%l\n so you can do "find /some/dir -type l -printf "%h/%l\n" 2>/dev/null | xargs -iL readlink -f 'L'"? Looks like a less convoluted version of post #3.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.