LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   4MLinux (https://www.linuxquestions.org/questions/4mlinux-115/)
-   -   What symlinks leading into itself are good for? (https://www.linuxquestions.org/questions/4mlinux-115/what-symlinks-leading-into-itself-are-good-for-4175685394/)

4ML220 11-17-2020 10:07 AM

What symlinks leading into itself are good for?
 
Hi, I found that there are some symlinks which are leading into itself in live 4MLinux filesystem /:
folder /usr/local/ is symlink leads into itself /usr/local/
folder /usr/samba/ is symlink leads into itself /usr/samba/

'Cos when I go into it - it goes into /usr/local/local/local/local/local/local/local/local/local/local/local/local/local/local/local/local/local/local/ ... and so on ... dependency rate on as far as many clicks ...

Just curious about it - what is it good for if it leads to (seems to me) 'nowhere'.
(both folders are empty at this time).


Q1:
Why they are just not simply 'straight' folder instead of symlink?



Q2:
Speaks about symlinks - can someone tell me please, what is good for in '/usr' folder to create additional symlinks,
but which leads back to basic '/' linux folders:
/etc
/var

Does some software or access rights need it?
(but 4MLinux uses root acct anyway so no access troubles I guess right?)

'Cos (seems to me as laik) the whole linux is based on directory structure rootpaths /etc & /var - so why additional symlinks inside /usr of the same please? Isn't the path '/etc' shorter than path '/usr/etc'?

Thank you guys for info or links to help me understand it.

pan64 11-17-2020 10:13 AM

/usr/local/local/local/.... that is not good, most probably that is a bug somewhere.
/usr/bin will lead to /bin (and so on), that can be useful, do not need to maintain both /usr/bin and /bin. But that has probably a historical reason.

4ML220 11-17-2020 11:48 AM

Thanx for reply & info :-).

Yes - and also symlink
/usr/samba/
... works the same way - clickin' into multiple /usr/samba/samba/samba/samba/samba/samba/samba/samba/samba/samba/samba/samba/samba/ ... and so on ... dependency rate on as far as many clicks ... (using pcmanfm).

In 4MLinux34.1 & Server too ... in "OutOfTheBox live CD" ... & I do rememember it was this way definitely already in versin 4MLinux30 (& Server) 'cos I was playing with it :-).

Could it do some errors with 'owerflow ...'? I can try how many times it can go into itself ...


About:
/usr/bin will lead to /bin (and so on), that can be useful, do not need to maintain both /usr/bin and /bin.

OK, thanx, now I've got it :-). I understand that /bin will be diferent for diferent users and system.
I just told that /etc & /var is always only the one version - for all of them, so just the one in root is enough.
I'm sorry, my apologize here :-).

zk1234 11-17-2020 12:24 PM

Hi,

That's only an illusion :-)
This is a part of the 4MLinux sysinit script:
Code:

busybox rm -fr /usr/etc
busybox ln -s /etc /usr/etc
busybox rm -fr /usr/var
busybox ln -s /var /usr/var
busybox rm -fr /usr/local
busybox ln -s /usr /usr/local
busybox rm -fr /usr/lib64
busybox ln -s /usr/lib /usr/lib64

The above means that, for example, there is only one /usr/etc symlink.
The rest is an illusion (= the way how file managers use symlinks).

.

4ML220 11-17-2020 02:49 PM

ps: Misspelling correction - please read in all my previous posts - the incorrect "told" in correct form "thought".
... damn autocorrection :-).
Than you.


OK, zk, thank you also for info, now I've got it & understand the answer for Q2 from abowe:
I can see also in pcmanfm that folders are symlinks and 'Properties' of it shows where it leads.



About Q1: I was just wonder if is there any purpose that symlinks:
/usr/local
/usr/samba
... goes into still the same folder in cycle on & on & on ...?

In pcmanfm if I click on that folder to get into folder - it goes (by each click) inside more and more multiple times:
/usr/local/local/local/local/local/local/local/local/local/local/local/local/local/ ... and so on ...
/usr/samba/samba/samba/samba/samba/samba/samba/samba/samba/samba/samba/samba/samba/ ... and so on ...
I just tried - maximum is 40 times.

Then it shows all symlinks in /usr as they are broken - so not only those two:
/usr/local
/usr/samba

... but show that broken are all symlinks which are in /usr - so it means also:
/usr/etc
/usr/lib64
/usr/var

I was just wonder why & what is it for :-).

zk1234 11-18-2020 10:55 AM

Quote:

Originally Posted by 4ML220 (Post 6186223)
I was just wonder why & what is it for :-).

There is only one possible answer: some applications in 4MLinux make use of these links.
For example, they look for libraries in /usr/local/lib (and not just /usr/lib).

.

ondoho 11-18-2020 02:33 PM

Quote:

Originally Posted by 4ML220 (Post 6186223)
'Cos when I go into it - it goes into /usr/local/local/local/local/local/local/local/local/local/local/local/local/local/local/local/local/local/local/ ... and so on ...

Technically, this symlink doesn't lead back into itself then.

About your question: there's no need to rely on your gui filemanager when going into system directories. There.
If you want to continue the discussion, post terminal output, e.g.:
Code:

ls -ld /usr/local

4ML220 11-23-2020 01:29 PM

The terminal output is:
lrwxrwxrwx 1 root root 1 Nov 17 16:22 /usr/local -> /usr

OK, I can see that you are right guys here, zk1234 + ondodo. Thank you.
Also you're right about the 'Technically, this symlink doesn't lead back into itself then.'
It realy doesn't.

It was my mystake 'cos just 'doing clickin'' on that symlink again & again i pcmanfm showes still the same screen with the same 'stuff' in the same folder.
Only later I realized that in the top addres bar is 'grouing up' line with more '/local' or '/samba' ... up to 40 times max.

It seems to it is not realy important - so I don't wanna waste your time here.
Thank you a lot :-)


All times are GMT -5. The time now is 09:55 AM.