Visit Our UNIX and Linux User Community


recurssion via symbolic links without allowing system to act recursively?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting recurssion via symbolic links without allowing system to act recursively?
# 1  
Old 09-16-2009
Question recurssion via symbolic links without allowing system to act recursively?

I tried looking up combinations of the keywords "infinite loop links" in google before causing a recurring post here... but alas, I couldn't find much.

Cause: I've created an infinite loop, in a way, of directories.
Problem:
  1. I'm not sure if this will crash a backup program (trying to backup directories, namely OS X's Time Machine)
  2. I'm not sure if this will crash an app that's trying to index my system (such as Gnome-Do in my Linux system, or Spotlight in OS X)
What I did (in Mac OS X, but I assume it applies to any *nix based system with this command) is created a symbolic link, with ln -s, to another directory. I did this because I prefer using the command line, and a file-manager's "alias"es don't come in handy, since I can't CD into them (shortcuts in Windows Explorer, alias in Finder, not sure how nautilus creates GUI links).

Another thing I like about making a link with the command line (this is key to me), is that once you move through the link and into its destination, you don't have to worry that your parent directory has now changed. Let me clarify: if I'm in the command line and I jump across my file heirarchy using a link, than when I cd ../ back out to continue what I was doing I will be placed in the directory where the link was (not into the destination's parent). attached is an exmaple to clarify this.
this is the recursion I'm talking about:
Code:
ossPlatform/cpp/practice> pwd
/Users/Shared/Dropbox/crossPlatform/cpp/practice
ossPlatform/cpp/practice> ls -la
total 56
drwxr-xr-x  11 jzacsh  wheel   374 Sep 16 11:50 .
drwxr-xr-x   4 jzacsh  wheel   136 Sep 16 12:29 ..
lrwxr-xr-x   1 jzacsh  wheel    47 Sep 16 11:50 comp132 -> /Users/Shared/Dropbox/Public/edu/comp132/source
drwxr-xr-x   8 jzacsh  wheel   272 Jul 17 23:08 macex
-rw-r--r--   1 jzacsh  wheel   413 Jul 16 12:04 pg109.1.cpp
-rw-r--r--   1 jzacsh  wheel   631 Jul 16 12:23 pg109.2.cpp
-rw-r--r--   1 jzacsh  wheel   470 Jul 16 12:32 pg109.3.cpp
-rw-r--r--   1 jzacsh  wheel  1149 Jul 16 12:54 pg111.5.cpp
-rwxr-xr-x   1 jzacsh  staff  1061 Jul 13 00:51 pg91.cpp
-rwxr-xr-x   1 jzacsh  wheel  1335 Jul 16 08:57 pg95.cpp
drwxr-xr-x   3 jzacsh  wheel   102 Jul 16 23:27 unixex
ossPlatform/cpp/practice> cd comp132; ls -la
total 48
drwxr-xr-x  7 jzacsh  staff   238 Sep 16 12:18 .
drwxr-xr-x  6 jzacsh  staff   204 Sep 16 11:17 ..
-rw-r--r--@ 1 jzacsh  staff  6148 Sep 16 12:18 .DS_Store
-rw-r--r--@ 1 jzacsh  staff   235 Sep 16 11:14 hw_09-16.cpp
-rw-r--r--  1 jzacsh  staff   311 Sep 16 11:18 in09-16_circle.cpp
-rw-r--r--  1 jzacsh  staff  1400 Sep 16 11:21 in09-16_miPgall.cpp
lrwxr-xr-x  1 jzacsh  staff    48 Sep 16 11:51 practice -> /Users/Shared/Dropbox/crossPlatform/cpp/practice
orm/cpp/practice/comp132> cd practice; ls -la
total 56
drwxr-xr-x  11 jzacsh  wheel   374 Sep 16 11:50 .
drwxr-xr-x   4 jzacsh  wheel   136 Sep 16 12:29 ..
lrwxr-xr-x   1 jzacsh  wheel    47 Sep 16 11:50 comp132 -> /Users/Shared/Dropbox/Public/edu/comp132/source
drwxr-xr-x   8 jzacsh  wheel   272 Jul 17 23:08 macex
-rw-r--r--   1 jzacsh  wheel   413 Jul 16 12:04 pg109.1.cpp
-rw-r--r--   1 jzacsh  wheel   631 Jul 16 12:23 pg109.2.cpp
-rw-r--r--   1 jzacsh  wheel   470 Jul 16 12:32 pg109.3.cpp
-rw-r--r--   1 jzacsh  wheel  1149 Jul 16 12:54 pg111.5.cpp
-rwxr-xr-x   1 jzacsh  staff  1061 Jul 13 00:51 pg91.cpp
-rwxr-xr-x   1 jzacsh  wheel  1335 Jul 16 08:57 pg95.cpp
drwxr-xr-x   3 jzacsh  wheel   102 Jul 16 23:27 unixex
ractice/comp132/practice> cd comp132; pwd
/Users/Shared/Dropbox/crossPlatform/cpp/practice/comp132/practice/comp132

in an effort to show you the same listing twice (two show you i have two directories linking to each other), it even becomes clear with a final pwd that I am descended recursively down into the directories (probably not a good thing).

bottom line:
  • will I end up crashing applications (like those I named earlier), by having this? or do most applications not actually follow links (other than some burning software)?
  • can i get the features I enjoy out of these symbolic links in some other way, without causing this mess? or should I not worry about it and keep doing this?
Thanks in advance! Smilie this forum's always been an awesome resource of info for me.
recurssion via symbolic links without allowing system to act recursively?-examplepng
# 2  
Old 09-16-2009
It depends on the application but most backup and indexing programs are smart enough to not follow symbolic links unless specifically instructed to do so. Some things like tar can even replicate them properly.

I'm still not entirely sure what you're doing with these symlinks though. Why not just put them in your home directory instead of scattering them throughout everything you use? Then you could do 'pushd ~/symlink' to cd comewhere, and 'popd' to get back. (pushd and popd are a directory stack.) It'd also let you make the links relative instead of absolute. And they'd be less deep than the things they link to, so recursion wouldn't be a problem.

Last edited by Corona688; 09-16-2009 at 05:02 PM..

Previous Thread | Next Thread
Test Your Knowledge in Computers #329
Difficulty: Easy
The NVidia named the GTX 1080 because it can only render at a 1920x1080 screen resolution.
True or False?

10 More Discussions You Might Find Interesting

1. Solaris

Symbolic links

Soft link,Hard link brief explanation (1 Reply)
Discussion started by: RAJU KAVATI
1 Replies

2. Ubuntu

How to find symbolic links recursively under a folder in Linux

Hi , I have folder which has almost 35000 objects, I need to find out or list the objects which are symbolic links. I tried f. I am not getting right Can you pls help Regards amv (5 Replies)
Discussion started by: amvarma77
5 Replies

3. UNIX for Dummies Questions & Answers

Symbolic links in UNIX

Hi, I have a file with more than 1 layers of soft links for it. For ex. ls -la .profile .profile@ -> /home/act/.profile_abc ls -la /home/act/.profile_abc@ -> .profile_final I want to get the name of the last file (i.e. .profile_final) when I refer to .profile using shell script. I... (2 Replies)
Discussion started by: deo_kaustubh
2 Replies

4. UNIX for Dummies Questions & Answers

Symbolic Links

Hi all, I have scoured the entire forum for this but to no avail unfortunately. Basically, I would like to remove my symbolic link from my folder name i.e. foldername -> /a/b/c/d/f where f is indeed a folder. I have tried rmdir but this does not work and in actual fact deletes the... (4 Replies)
Discussion started by: cyberfrog
4 Replies

5. Solaris

symbolic links between servers

Hi Guys... I want to create a link using ln -s for a directory that does not exist on the box. How do I do that? I had some files from Box A directory /d1/u01 and I copied the files across to another Box lets say Box B on directory /d2/u02. Now I want a link so that this path /d1/u01... (2 Replies)
Discussion started by: Phuti
2 Replies

6. UNIX for Dummies Questions & Answers

Symbolic links between directories

Hi all, lets consider 2 directories test1 and test2. I want to link test2 to point to test1, how do u do this? (4 Replies)
Discussion started by: Mr. Zer0
4 Replies

7. AIX

Symbolic Links

I am linking a directory as follows: ln -sf /home/xxx/userid/real_files/* /home/xxx/userid/linked_files This gives me symbolic links for all the files in the real_files directory in the linked_files directory. My question is, if I go and remove a file in the real_files directory and then go... (1 Reply)
Discussion started by: rcarnesiii
1 Replies

8. Solaris

cp a dty without symbolic links?

Hi, - we have copy (cp command) to do to save all the contents of a dty BUT we dont want to copy the files corresponding to symbolic links contained whithin this dty - the box is a sun solaris one - and the cp commande do not say avything about that? thanks for help Jakez (7 Replies)
Discussion started by: JAKEZ
7 Replies

9. UNIX for Dummies Questions & Answers

Symbolic Links for a File

how do i get the list of symbolic link names for a particular file programatically (4 Replies)
Discussion started by: b_u_n_1234
4 Replies

10. UNIX for Dummies Questions & Answers

Finding symbolic links

How can I find all symbolic links across the network to a directory (2 Replies)
Discussion started by: mehtad
2 Replies

Featured Tech Videos