LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to search for a link to a certain path? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-search-for-a-link-to-a-certain-path-757514/)

anon091 09-24-2009 10:48 AM

How to search for a link to a certain path?
 
Hi guys. I have a /data and /backup. on backup there is a folder called Info that has a bunch of data on it, but its not shared through Samba. So what I'm thinking is that on one of my Samba shares on data there is a folder which is really just a link to that /backup/Info folder. Is there an easy way to search through /data to see if there's a link to it, or do i have to manually go through and do a ton of ls's?

paulsm4 09-24-2009 11:04 AM

The "find" command might be just what you're looking for.

Google for "linux find command examples", or try "man find".

'Hope that helps .. PSM

anon091 09-24-2009 11:14 AM

I read the man page for find, but I'm still confused. if i use lname will that search for my search term in the name of where the link points to?

catkin 09-24-2009 11:35 AM

find is a notoriously difficult command to master and its man page is not an easy introduction (although it is an impeccably correct reference). As a result there are lots of web pages about using find but I have not yet found one which explains how find works. Mostly they just give HOWTO examples of common tasks which is fine until you want to do something different and need to master find to use its immense power and flexibility.

You mentioned samba but that's for mounting Linux file systems on Windows in which case symlinks are meaningless on the Windows system. Do we need to know about your samba setup to understand the problem or is the problem within a Linux environment and just happens to be about a file system which is shared by samba?

anon091 09-24-2009 11:38 AM

My problem is that nobody can tell me anything about that Info folder I have. So I was taking a guess and thinking that maybe there was a folder on one of my Samaba shares on /data which people dropped files into, but it was really a link putting the files in /backup/Info instead, maybe to save space on /data.

If I do a ls in every single directory under /data that is shared out through samba I could see this probably, but that would take me hours of manual work.

catkin 09-24-2009 11:57 AM

Do you mean that /data is shared via Samba and that client systems (probably Windows) users are putting files in a directory on the share which directory is actually a symlink to /backup/Info so the files end up in /backup/Info?

So what you want to do is find symlinks on /data that point to /backup/Info? If that is correct then Samba is irrelevant to the question. Or have I not understood yet?

anon091 09-24-2009 12:00 PM

You have it right. I want to find symlinks on /data that point to /backup/Info. Samba isn't part of the problem, was just giving some background so you understood the situation/setup.

catkin 09-24-2009 12:14 PM

This might work
Code:

find /data -lname '*/backup/Info'
but not if the symlink goes via other symlinks to eventually point at /backup/Info.

If you dont have too many symlinks on /data then how about finding them all with
Code:

find /data -lname '*'
Alternatively you could configure Samba not to action symlinks.

anon091 09-24-2009 12:34 PM

ok, thanks, it didn't find anything so there must not be any.

catkin 09-24-2009 12:38 PM

What were the original problem symptoms that made you suspect there might be some synlink(s) on /data, pointing to /backup/Intro?

anon091 09-24-2009 12:45 PM

The files have the same owner and group as those on some of the samba shares on data. it was either that or someone did a copy of hte files from the server as that user, but nobody here knows.


All times are GMT -5. The time now is 01:29 AM.