commands
ln — create hard or symbolic links
Creates a hard link by default, or a symlink with -s. Hard links share inode identity and normally cannot cross filesystems; symbolic links store path text, resolved relative to their own parent for relative targets. Examples assume a fresh chapter files lab.
Formal Syntax & Structure
linux syntaxlinux
ln [OPTION]... TARGET LINK_NAMEParameters & Attributes
| Name | Type | Description |
|---|---|---|
| -s | option | Create symbolic link |
| TARGET | operand | Existing object for hard link; path text for symlink |
| LINK_NAME | operand | New name |
Return Value
filesystem change and exit status
GNU ln returns 0 when link creation succeeds and nonzero on failure. Verify hard-link inode identity or the stored symlink target; a successful symlink creation does not require the target to exist.
Working Example
Example Snippetlinux
ln -s ../notes/hello.txt archive/shortcut