Seth Woolley's Man Viewer

Manual for link - man 2 link

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

LINK(2)                    Linux Programmer's Manual                   LINK(2)

       link(1,2) - make a new name for a file(1,n)

       #include <unistd.h>

       int link(1,2)(const char *oldpath, const char *newpath);

       link(1,2)  creates  a  new  link(1,2)  (also known as a hard link(1,2)) to an existing

       If newpath exists it will not be overwritten.

       This new name may be used exactly as the old  one  for  any  operation;
       both names refer to the same file(1,n) (and so have the same permissions and
       ownership) and it is impossible to tell which name was the  `original'.

       On  success,  zero is returned.  On error(8,n), -1 is returned, and errno is
       set(7,n,1 builtins) appropriately.

       EACCES Write access(2,5) to the directory containing newpath is  denied,  or
              search  permission  is  denied for one of the directories in(1,8) the
              path prefix of  oldpath  or  newpath.   (See  also  path_resolu-

       EEXIST newpath already exists.

       EFAULT oldpath or newpath points outside your accessible address space.

       EIO    An I/O error(8,n) occurred.

       ELOOP  Too many symbolic links were encountered in(1,8) resolving oldpath or

       EMLINK The  file(1,n)  referred to by oldpath already has the maximum number
              of links to it.

              oldpath or newpath was too long.

       ENOENT A directory component in(1,8) oldpath or newpath does not exist or is
              a dangling symbolic link.

       ENOMEM Insufficient kernel memory was available.

       ENOSPC The device containing the file(1,n) has no room for the new directory

              A component used as a directory in(1,8) oldpath or newpath is not, in(1,8)
              fact, a directory.

       EPERM  oldpath is a directory.

       EPERM  The  filesystem  containing oldpath and newpath does not support
              the creation of hard links.

       EROFS  The file(1,n) is on a read-only filesystem.

       EXDEV  oldpath and newpath are not on the same filesystem.

       Hard links, as created by link(1,2), cannot span filesystems. Use symlink if(3,n)
       this is required.

       SVr4,  SVID, POSIX, BSD 4.3, X/OPEN.  SVr4 documents additional ENOLINK
       and EMULTIHOP  error(8,n)  conditions;  POSIX.1  does  not  document  ELOOP.
       X/OPEN does not document EFAULT, ENOMEM or EIO.

       On  NFS  file(1,n)  systems,  the  return  code may be wrong in(1,8) case the NFS
       server performs the link(1,2) creation and dies before it can say  so.   Use
       stat(1,2)(2) to find out if(3,n) the link(1,2) got created.

       ln(1),  open(2,3,n)(2),  path_resolution(2),  rename(1,2,n)(2),  stat(1,2)(2), symlink(2),

Linux 2.6.7                       2004-06-23                           LINK(2)

References for this manual (incoming links)