1752808 Members
5969 Online
108789 Solutions
New Discussion юеВ

Re: symbolic link loops

 
SOLVED
Go to solution
Mike Boswell_1
Frequent Advisor

symbolic link loops

Anyone have a suggestion on how I can identify sym link loops and or repair?

[root@webdvl via]# pwd
/opt/http/docs/company/via
[root@webdvl via]# ll -d company
lrwxrwxrwx 1 apache apache 22 Jan 21 10:47 company -> /opt/http/docs/company


6 REPLIES 6
Patrice Le Guyader
Respected Contributor
Solution

Re: symbolic link loops

Hello,

Try this :

find / -links 1 -follow|grep symbolic

the result will be an error message like :

: Too many levels of symbolic links

hope this helps.
Kenavo
Pat.
Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.
Mike Boswell_1
Frequent Advisor

Re: symbolic link loops

Thanks for the quick reply. Your suggestion put me on the correct track but yours came back empty.

What does this tell me?

find /opt/http/docs -links +40 -follow

It gives me 37 matches.
TTr
Honored Contributor

Re: symbolic link loops

The -links option of the find command does not do what is requested here. The -links option finds the hard symbolic links that a file might have.

I don't know of any tricks to find the circular symbolic links other than brute force. You can type the following in a script or inline.

find / -type l |
while read link
do
dest=`ll $link | awk '{print $NF}'`
if [ $link = $ dest ]
then
echo $link is circular
fi
done
Mike Boswell_1
Frequent Advisor

Re: symbolic link loops

Thanks TTr,

My issue is not a file linked to itself but file linked before itself. I am looking for a way to have the following type of example identified:

/opt/http/docs/westcor/company/via/company/via/company/via/company/via/company/via/company/via/company/via/company/via/company/via/company/via/company/via/company/via/company/via/company/via

The only way I can see this path is to 'cd' all the way. I don't see this path w/ 'find'.
Mike Boswell_1
Frequent Advisor

Re: symbolic link loops

This turned up 2 results and I deleted them.

find /opt/http/docs/ -type l | xargs ls -la | awk '{printf"echo %s | grep %s\n\n", $(NF-2),$NF}'
Mike Boswell_1
Frequent Advisor

Re: symbolic link loops

find /opt/http/docs/ -type l | xargs ls -la | awk '{printf"echo %s | grep %s\n", $(NF-2),$NF}' | awk '{system($0)}'