Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

circular soft links

Posted on 2002-06-20
13
Medium Priority
?
403 Views
Last Modified: 2013-12-26
I think I have softlinks that point to themselves somewhere on my system.  Is there a way to find and
diagnose circular links?
0
Comment
Question by:cotec1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +2
13 Comments
 
LVL 21

Expert Comment

by:tfewster
ID: 7096939
ls -l `find . -type l -exec ls -l {} \; | awk '{print $NF}'` |grep "^l"
will list links to links [not very good practice, obviously!] - Hopefully that list will be short enough check manually.
0
 
LVL 21

Expert Comment

by:tfewster
ID: 7096998
In this scenario:
/tmp/junk> ls -lR
total 0
drwxr-xr-x   2 root       sys             96 Jun 20 19:20 d1
lrwxr-xr-x   1 root       sys              2 Jun 20 19:15 l1 -> l2
lrwxr-xr-x   1 root       sys              2 Jun 20 19:14 l2 -> l1

./d1:
total 0
lrwxr-xr-x   1 root       sys             12 Jun 20 19:20 l3 -> /tmp/junk/l1
lrwxr-xr-x   1 root       sys             12 Jun 20 19:17 ld1 -> /tmp/junk/d1

results in:
/tmp/junk> find . -follow -exec ls -ld {} \;
drwxr-xr-x   3 root       sys             96 Jun 20 19:16 .
drwxr-xr-x   2 root       sys             96 Jun 20 19:20 ./d1
find: ./d1/ld1 creates a cycle
lrwxr-xr-x   1 root       sys             12 Jun 20 19:17 ./d1/ld1 -> /tmp/junk/d1
find: cannot stat ./d1/l3
find: cannot stat ./l1
find: cannot stat ./l2

Of course, `find` may return the "cannot stat" error for other reasons, but it's a useful pointer to problems ;-)
0
 
LVL 38

Expert Comment

by:yuzh
ID: 7097708
Hi cotec1,

   You put this question on Soalris area as well, you should create a link for the question to save to points.

    I don't think you can make a  symbolic link to point to themselves.

Just ask yourseft a question, do you think the following command work ?
  ln -s test test
  The answer is NO !
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Expert Comment

by:ahoffmann
ID: 7098034
>  I don't think you can make a  symbolic link to point to themselves.
you can, unfortunately :-(
The answer is YES ! (at least for some flaviours of UNIX)
0
 

Author Comment

by:cotec1
ID: 7098492
They don't actuall point back to themselves.  I should have been more specific in the description.  The links are causing our backups to go in to a loop, for instance:  There may be a link /home/cotec1/link_example > /home/cotec1

It points back to the directory that the link is in causing the backups to get trapped in a loop.

That is what I am trying to find.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7098661
to narrow down all possibilities: you're only interested in links pointing the a part of the physical part where it resides.
That would make a search easyer
0
 
LVL 21

Expert Comment

by:tfewster
ID: 7098668
If you're using Solaris, my earlier suggestions won't work (I guess I can't persuade you to switch to HP-UX? ;-)

However, what are you using for backups? Even tar and cpio will copy links as links, rather than following the link (unless you specify the h option to tar)
0
 

Author Comment

by:cotec1
ID: 7098690
We are using a no-frills, no-cost NT backup to a Mapped drive through Samba.  
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7098700
.. NT .. and which people adicted to NT, know about so sophisticated things like symbolic links? Just joking ...
0
 
LVL 38

Expert Comment

by:yuzh
ID: 7098772
Why don't you just use Solaris to backup, a symbole link cost you no almost no tape space!
0
 

Author Comment

by:cotec1
ID: 7098804
I have been working with our IT department to change our backup process.  The mode we are in now is temporary.  I think for a temp solution I am going to create a tar file for the backup and backup the tar file through NT/Samba.
0
 
LVL 38

Accepted Solution

by:
yuzh earned 300 total points
ID: 7098884
use: tar cvf dev-file-or-file file-list
will do the job for you.

    do not use:
    tar cvhf dev-file-or-file file-list
    -h it follow symbolic links and try to copy the normal
       file, you'll end up have mult-copies of the file in your tape.
0
 
LVL 1

Expert Comment

by:bearware
ID: 7365476
If your backup interperates the likes as it does instead of just copying them as discussed above. Then when you restore a backup you WILL NOT get back to the original data symlinks will be lost, and you make need a biger disk drive.

Also symlinks to directorys closer to the root will probably be common and it will be futile to hunt them.
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question