Using links – HP NonStop G-Series User Manual

Page 109

Advertising
background image

a single disk partition. (A disk partition is a physical disk, or a portion of one, that has been
prepared to contain file directories.)

Using Links

To link files in the same file system, use the following command format:

ln /dirname1/filename1 /dirname2/filename2

The /dirname1/filename1 entry is the pathname of an existing file. The
/dirname2/filename2

entry is the pathname of a new filename to be linked to the existing

/dirname1/filename1

. The dirname1 and dirname2 arguments are optional if you are

linking files in the same directory.

In the following example, the ln command links the new filename checkfile to the existing file
named file3:

$ ln file3 checkfile

Use the more command to verify that file3 and checkfile are two names for the same file:

$ more file3

The system displays the following:

You will find that vi is a useful
editor that has many features.

Now display the text of checkfile:

$ more checkfile

The system displays the following:

You will find that vi is a useful
editor that has many features.

Notice that both file3 and checkfile contain the same information. Any change that you
make to the file under one name will show up when you access the file by its other name. Updating
file3

, for example, also updates checkfile.

How Links Work—Understanding Filenames and inode-numbers

Each file has a unique identification number called an “inode-number.” The inode-number refers
to the file itself—data stored at a particular location—rather than to the filename. The i-number
distinguishes the file from other files within the same file system.

A directory entry is simply a link between a filename and an inode-number that represents a physical
file. It is this relationship between filenames and files that enables you to link multiple filenames to
the same physical file; that is, to the same inode-number. To display the inode-numbers of files in
your current directory, use the ls command with the -i (print i-number) flag in the following form:

ls -i

Now, examine the identification numbers of the files in your login directory. The number preceding
each filename in the listing is the inode-number for that file.

$ ls -i

1079 checkfile 1077 file1 1078 file2 1079 file3

The inode-numbers in your listing will probably differ from those shown in this example. However,
the important thing to note is the identical inode-numbers for file3 and checkfile, the two
files linked in the previous example. In this case, the inode-number is 1079.

Because an inode-number represents a file within a particular file system, hard links cannot exist
between separate filesets.

Linking Files (ln) 109

Advertising
This manual is related to the following products: