![]() |
Why symlinks do not contain the paths?
Why symlinks do not contain the paths? Everywhrre you read about symlinks you are told the symlink file data contains the target file path+name but when you check the file it contains only the name. Where is the path stored? I am not interested in the actual command to find the path. Iam interested to know where the path is actially stored and maybe an explanation why is not together with the name?
|
What did you do to “check the file”?
On my system Code:
ls -l |
As I mentioned I am interested to know where the path is actually stored, because it is common belief that the path+name is stored as a text in the file's data/content. If you read the file as a text you do see the name of the target file which corresponds with the file size in bytes of the symlink file and indicate that the path is not stored togetber with the name. The line commands (including the one you used) process the symlink file then show the target path. This doesn't answer my question of where the path is stored?
|
Quote:
|
No offense but I think you should go back to basics before giving advice on forums. I will give you just one good link where you could start:
https://manpages.debian.org/buster/m...link.7.en.html "A symbolic link is a special type of file whose contents are a string that is the pathname of another file, the file to which the link refers" |
How are you reading the contents of the symlink?
From man symlink: Code:
A symbolic link is a special type of file whose contents |
There are fast and slow symbolic links. With modern linux filesystems inodes have the capability of directly storing data of small files so with small path names it would be stored within.
https://unix.stackexchange.com/quest...-slow-symlinks |
Quote:
Quote:
Quote:
The path is still a pointer to the inode of the original file; if you move/delete that file, that invalidates the link, and causes a dangling link. A hardlink is different, allowing you to move the file on the same filesystem without breakage. |
Quote:
|
Are you sure that you're not checking a symlink that actually does contain only the name? They exist.
Code:
❯ touch a.txt And anyway, you need to answer this question that was asked of you repeatedly: Quote:
Quote:
Post screenshots. |
|
Quote:
|
@Stefan69
The answer to your question is going to be filesystem-specific, but I found you information on how symbolic links are implemented in ext4. https://ext4.wiki.kernel.org/index.p...Symbolic_Links |
You learn something every day! I had no idea that some symbolic links store the link in the inode. Just out of curiosity, do such links use a data block at all?
I just took a look at the links in my /boot directory. They are of different sizes running from 24 to 38 bytes and the size correlates exactly with the length of the link string. |
Quote:
Code:
$ ls -ls config vmlinuz Code:
$ ln -s 'Short link does not use data blocks' fast |
All times are GMT -5. The time now is 09:57 PM. |