Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
3.271 Pathname
A string that is used to identify a file. In the context of POSIX.1-2017, a pathname may be limited to {PATH_MAX} bytes, including the terminating null byte. It has optional beginning <slash> characters, followed by zero or more filenames separated by <slash> characters. A pathname can optionally contain one or more trailing <slash> characters. Multiple successive <slash> characters are considered to be the same as one <slash>, except for the case of exactly two leading <slash> characters.
3.170 Filename
A sequence of bytes consisting of 1 to {NAME_MAX} bytes used to name a file. The bytes composing the name shall not contain the <NUL> or <slash> characters. In the context of a pathname, each filename shall be followed by a <slash> or a <NUL> character; elsewhere, a filename followed by a <NUL> character forms a string (but not necessarily a character string). The filenames dot and dot-dot have special meaning. A filename is sometimes referred to as a "pathname component". See also Pathname.
They may resolve to the same canonicalized absolute pathname, depending on $PWD. Or, in case of symlinks, depending on where the symlink is.
Code:
$ realpath /usr/lib/../bin/bash
/bin/bash
It's often a good idea to not use absolute pathnames in symlinks. For example, if you create a tar archive and extract it to somewhere else, absolute links will stop working correctly. Or, if you mount a file system to a different place in the tree, like mount a linux os root under /mnt of another linux os.
Last edited by Petri Kaukasoina; 05-01-2024 at 05:36 AM.
There is no 'path' in a symlink...it's a pointer to the inode of the resource you linked to.
I believe that you are referring to a "hard link," TB0ne, not a "symbolic one.
A hard-link is a second directory-entry which refers to the same internal file ("inode"). Whereas a symbolic-link is, indeed, a tiny file containing a filename reference, which Linux resolves by trying to find and open the target file. (You don't know if it will [still ...] work until and unless you try it.)
I believe that you are referring to a "hard link," TB0ne, not a "symbolic one.
A hard-link is a second directory-entry which refers to the same internal file ("inode"). Whereas a symbolic-link is, indeed, a tiny file containing a filename reference, which Linux resolves by trying to find and open the target file. (You don't know if it will [still ...] work until and unless you try it.)
Indeed so, and michaelk's link provided a much better explanation. It referenced inodes in the context I was thinking of, but you are correct.
I believe that you are referring to a "hard link," TB0ne, not a "symbolic one.
That's why, if you delete the actual file, the symlink file will be left dangling and invalid. This is usually signaled in displays with a different colour or a highlight. Whereas if you delete a file with a hard link to it, the linked name still works and nothing has really changed.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.