Ln

From Wsms

Jump to: navigation, search

Note: This page should be titled ln (all lowercase). It is Ln due to technical limitations of Mediawiki.

ln creates a link from an existing file (or directory if you use a symbolic link).

common usage

Make a hard link to a file:

ggeller@roosevelt:~/testdir$ ls -l
total 4
-rw-r--r-- 1 ggeller ggeller 21 2008-07-31 12:12 source
ggeller@roosevelt:~/testdir$ ln source source.lnk
ggeller@roosevelt:~/testdir$ ls -l
total 8
-rw-r--r-- 2 ggeller ggeller 21 2008-07-31 12:12 source.lnk
-rw-r--r-- 2 ggeller ggeller 21 2008-07-31 12:12 source

Notice that the number of links to the inode is now 2. You can see the inode with the I option to ls:

ggeller@roosevelt:~/testdir$ ls -li
total 8
1081503 -rw-r--r-- 2 ggeller ggeller 21 2008-07-31 12:12 source
1081503 -rw-r--r-- 2 ggeller ggeller 21 2008-07-31 12:12 source.lnk

Using the -s option to make a soft link:

ggeller@roosevelt:~/testdir$ ln -s /etc/apache2/httpd.conf .
ggeller@roosevelt:~/testdir$ ls -l
total 8
lrwxrwxrwx 1 ggeller ggeller 23 2008-07-31 12:24 httpd.conf -> /etc/apache2/httpd.conf
-rw-r--r-- 2 ggeller ggeller 21 2008-07-31 12:12 source
-rw-r--r-- 2 ggeller ggeller 21 2008-07-31 12:12 source.lnk

see also

man ln

Personal tools