path: root/bin/ln
diff options
authorjoel <>2012-11-02 22:32:47 +0000
committerjoel <>2012-11-02 22:32:47 +0000
commit2f363dd858258e0bf0d6976ab07850b49effa02b (patch)
tree28b1b9d331ac7442894ce0c6a7fd8b1357d6765d /bin/ln
parentb683696bb32f0a9cf874fc7bf2aaa8925cc01948 (diff)
Add a couple of examples.
Obtained from: OpenBSD
Diffstat (limited to 'bin/ln')
1 files changed, 65 insertions, 1 deletions
diff --git a/bin/ln/ln.1 b/bin/ln/ln.1
index c180123..fcf97da 100644
--- a/bin/ln/ln.1
+++ b/bin/ln/ln.1
@@ -32,7 +32,7 @@
.\" @(#)ln.1 8.2 (Berkeley) 12/30/93
.\" $FreeBSD$
-.Dd July 17, 2009
+.Dd November 2, 2012
.Dt LN 1
@@ -212,6 +212,70 @@ No options may be supplied in this simple mode of operation,
which performs a
.Xr link 2
operation using the two passed arguments.
+Create a symbolic link named
+.Pa /home/src
+and point it to
+.Pa /usr/src :
+.Dl # ln -s /usr/src /home/src
+Hard link
+.Pa /usr/local/bin/fooprog
+to file
+.Pa /usr/local/bin/fooprog-1.0 :
+.Dl # ln /usr/local/bin/fooprog-1.0 /usr/local/bin/fooprog
+As an exercise, try the following commands:
+.Bd -literal -offset indent
+# ls -i /bin/[
+11553 /bin/[
+# ls -i /bin/test
+11553 /bin/test
+Note that both files have the same inode; that is,
+.Pa /bin/[
+is essentially an alias for the
+.Xr test 1
+This hard link exists so
+.Xr test 1
+may be invoked from shell scripts, for example, using the
+.Li "if [ ]"
+In the next example, the second call to
+removes the original
+.Pa foo
+and creates a replacement pointing to
+.Pa baz :
+.Bd -literal -offset indent
+# mkdir bar baz
+# ln -s bar foo
+# ln -shf baz foo
+Without the
+.Fl h
+option, this would instead leave
+.Pa foo
+pointing to
+.Pa bar
+and inside
+.Pa foo
+create a new symlink
+.Pa baz
+pointing to itself.
+This results from directory-walking.
+An easy rule to remember is that the argument order for
+is the same as for
+.Xr cp 1 :
+The first argument needs to exist, the second one is created.
.Fl h ,
OpenPOWER on IntegriCloud