How do I create a link to a file on linux?
Like a symbolic link?
ln -s /path/to/real/file linkname
That is exactly what I mean. Thanks
And for a "hard" link, leave off the -s....
But does anyone really use hard links?
Whats the difference?
Originally posted by dalecosp But does anyone really use hard links?
Not me...
Originally posted by piersk Whats the difference?
By default, ln makes hard links. A hard link to a file is indistinguishable from the original directory entry; any changes to a file are effectively independent of the name used to reference the file. Hard links may not normally refer to directories and may not span file systems. A symbolic link contains the name of the file to which it is linked. The referenced file is used when an open(2) operation is performed on the link. A stat(2) on a symbolic link will return the linked-to file; an lstat(2) must be done to obtain information about the link. The readlink(2) call may be used to read the contents of a symbolic link. Symbolic links may span file systems and may refer to directories.[/i][/quote]See, I can RTFM (or at least CNPTFM....) A hard link is actually a second copy of a file; the two files are "linked" so that an operation on one will affect the other in terms of content, but the linked file is independent in terms of "file" operations. If you mv or rm a linked file, the "hard link" file will still be in the original location. Basically, the only use I can think of for a hard link is so you can have group access to a file without leaving your homedir. Not too applicable on today's "single user multi-user" systems.... ? And, FWIW, I've never used hard links, either.
By default, ln makes hard links. A hard link to a file is indistinguishable from the original directory entry; any changes to a file are effectively independent of the name used to reference the file. Hard links may not normally refer to directories and may not span file systems.
A symbolic link contains the name of the file to which it is linked. The referenced file is used when an open(2) operation is performed on the link. A stat(2) on a symbolic link will return the linked-to file; an lstat(2) must be done to obtain information about the link. The readlink(2) call may be used to read the contents of a symbolic link. Symbolic links may span file systems and may refer to directories.[/i][/quote]See, I can RTFM (or at least CNPTFM....)
A hard link is actually a second copy of a file; the two files are "linked" so that an operation on one will affect the other in terms of content, but the linked file is independent in terms of "file" operations. If you mv or rm a linked file, the "hard link" file will still be in the original location.
Basically, the only use I can think of for a hard link is so you can have group access to a file without leaving your homedir. Not too applicable on today's "single user multi-user" systems.... ?
And, FWIW, I've never used hard links, either.
Behold the mighty MAN!!!! man pages are a Linux users best friend 🙂