Module 76 ln

Previous Table of Contents Next


Module 76
ln

DESCRIPTION

The external ln command links a new filename to an existing file. It is used to provide multiple filenames to the same physical data. It has two formats that allow you to:

   Create an additional filename for an existing file.
   Create corresponding filenames in a different directory for a set of existing files.

NOTE:    
The link name (new filename) must reside in the same file system. Directory names cannot be linked.

There is another type of link called a symbolic link. A symbolic link allows you to link filenames across different file systems. It also allows the linking of directory names.

Symbolic links are often referred to as soft links. This is because the link is not made using the actual inode number. Instead, it is performed by creating a simple name reference to the existing file or directory.

COMMAND FORMAT

The general formats of the ln command follow.

 ln [ -fns ] filename linkname      ln [ -fns ] filename_list directory 

BSD (Berkeley)
ln [ -s ] filename [ linkname ]
ln [ -s ] filename_list directory

Options

The options that may be used to control how ln functions follow.

-f F orce the ln to occur. The response of yes is assumed and the link is performed. No interactive response is requested . Only works on hard links.
If the standard input is not the terminal keyboard, then the -f option is assumed.
-n If the link name is an existing file, do not overwrite the contents of the file. The -f option overrides this option.
-s Causes a s ymbolic link to be created. A symbolic link contains the name of the file to which it is linked, unlike a normal link which contains the inode number. Symbolic links may span file systems and refer to directories.

BSD (Berkeley)
-s Same as SV

Arguments

The following list describes the arguments that may be passed to the ln command.

filename The existing file that will be linked to with linkname.
filename_list @T2 = The list of files that will be linked to in a different directory.
linkname The new filename linked to the existing file.
directory The directory where links are created to each file in the filename_list.

FURTHER DISCUSSION

The first format creates an additional filename for an existing file. The linkname is entered into the directory with the same inode number as the existing file.

The new linkname and the existing filename cannot be the same full pathname. They may have the same filename, providing they reside in different directories. If the new linkname is an existing filename, its contents are lost.


BSD (Berkeley)
The BSD version of link does not allow the destruction of existing data. If a filename already exists and you try to use it for a linkname, ln complains that the file already exists.

The second format creates a link for one or more files in a specified directory. A link is created in the directory for each file listed in the filename_list.

A link is an entry in a directory pointing to an inode that exists and has a filename. Therefore, no new disk space is used other than the directory entry. Once a link has been created, the two filenames point to the same inode and are equivalent except in their symbolic name.

Before ln performs the link, it checks the linkname file for write permissions. If you do not have write permissions on the destination, ln will display the mode ( chmod ; Module 17) and request a response from standard input. If the input line you type starts with a y, ln attempts to link the linkname to the existing file. If the ownership permissions allow you to write to the target, the move will occur. If you do not have permission to write to the target, the mv will fail.

Some common formats are:

ln personal_ltr pl # links the pl name to the personal_ltr file.
ln memo* ../grp/memos # links all memo files to directory @H2 =


Previous Table of Contents Next

Copyright Wordware Publishing, Inc.


Illustrated UNIX System V
Illustrated Unix System V/Bsd
ISBN: 1556221878
EAN: 2147483647
Year: N/A
Pages: 144
Authors: Robert Felps

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net