Solved

circular soft links

Posted on 2002-06-20
4
1,202 Views
Last Modified: 2013-12-27
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
  • 2
4 Comments
 
LVL 38

Expert Comment

by:yuzh
ID: 7097661
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
 
LVL 5

Expert Comment

by:nebeker
ID: 7120331
yuzh - yes, you can have symbolic links point to themselves -- they just have to be in different directories...

For example, try this:

mkdir 1
mkdir 2
ln -s ./1/mylink  ./2/mylink
ln -s ./2/mylink  ./1/mylink

The links are now circular....

cotec1:

Here's a command that I tried out and it seems to do a little of what you want:

find -follow -type l  

(that's an ell after the word "type")

It will produce an error message similar to this for each invalid symlink:

find: <link name>: No such file or directory


However, this will report ALL broken symlinks.  I'm not really sure how to figure out (programatically) if the links are circular or not...  But, using the output of the find command, you should be able to track this down manually -- pretty quickly, too, unless you've got tons and tons of broken links...

0
 
LVL 2

Expert Comment

by:blowfish
ID: 7125335
You certainly can create a symlink that points to itself ...

[blowfish@blowfish blowfish]$ ls -l xyzzy
lrwxrwxrwx    1 blowfish blowfish        5 Jul  2 13:26 xyzzy -> xyzzy

Now, how did I do that?

[blowfish@blowfish blowfish]$ ln -s xyzzy .

How to find them?  I will post my answer in a few moments

0
 
LVL 2

Accepted Solution

by:
blowfish earned 100 total points
ID: 7125387
I ran the following test case on Linux, here's the output:

[blowfish@blowfish blowfish]$ mkdir -p testing/symbolic/links
[blowfish@blowfish blowfish]$ cd testing/symbolic/links
[blowfish@blowfish links]$ ln -s castle .
[blowfish@blowfish links]$ ls -l
total 0
lrwxrwxrwx    1 blowfish blowfish        6 Jul  2 13:37 castle -> castle
[blowfish@blowfish links]$
[blowfish@blowfish links]$ cd
[blowfish@blowfish blowfish]$ find . -type l -print -exec ls -Ld {} 2>&1 \;| grep 'Too many levels of symbolic links'
ls: ./testing/symbolic/links/castle: Too many levels of symbolic links


I ran the following test case on Solaris 7, here's the output:
blowfish@rocco:(/homes/rocco/blowfish) $ mkdir -p testing/symbolic/links
blowfish@rocco:(/homes/rocco/blowfish) $ cd testing/symbolic/links  
blowfish@rocco:(/homes/rocco/blowfish/testing/symbolic/links) $ ln -s castle .
blowfish@rocco:(/homes/rocco/blowfish/testing/symbolic/links) $ ls -l
total 0
lrwxrwxrwx   1 blowfish  rocco           6 Jul  2 13:50 castle -> castle
blowfish@rocco:(/homes/rocco/blowfish/testing/symbolic/links) $ cd -
/homes/rocco/blowfish
blowfish@rocco:(/homes/rocco/blowfish) $ find . -type l -print -exec ls -Ld {} 2>&1 \;| grep 'exceeds MAXSYMLINKS'
./testing/symbolic/links/castle: Number of symbolic links encountered during path name traversal exceeds MAXSYMLINKS

Hope this answers your question.

regards,

--frankf
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSH commands for Nas4free 21 506
Skill Development 15 195
Install MySQL 5.6 and PHP on Centos Linux 6 162
Control Number of Log Files -Perl 7 94
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

730 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