Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Ln-establish a connection between files

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

LN (1) LN (1)

NAME

Ln-establish a connection between files

Overview

Ln [options] source [dest]

Ln [options] source...directory

POSIX options:

[- f]

GNU option (abbreviation):

[- bdfinsvF] [- S backup-suffix] [- V {numbered, existing, simple}] [--help] [--version] [-]

Description

In the Unix world, there are two concepts of link', generally called hard connection and soft connection. A hard connection is just a file name. (a file can have several file names, only changing the last file name from

Delete this file from the disk. The number of file names is determined by ls (1). All file names are in the same state, so there is no such thing as "source name". Usually a file in a file system

All names contain the same data information, but this is not necessary. A soft connection (or symbolic connection) is completely different: it is a small specified file that contains path information. Therefore, SoftLink

You can then point to files in different file systems (such as files on different machine file systems mounted by NFS), or even to a file that doesn't necessarily exist. The soft connection file is accessed (department call

When open (2) or stat (2)), the operating system replaces the access intervention point of the file with the path contained in the file, thus realizing the access to the specified file. (use the commands rm (1) and unlink (2) to delete the connection

However, it does not delete the file that the file points to. The system specifies that lstat (2) and readlink (2) are called to read the status of the connection file and the file it refers to. Whether it is to operate on the soft connection file or on the pointed file

Because there are different system calls in different operating system components, there are differences. )

Ln creates connections between files. By default, a hard connection is generated, and with the-s option, a symbolic (soft) connection is generated.

If only one file name is given, ln will generate a connection to the file in the current directory, that is, a link in the current directory with the same name as the file (the last).

If the last parameter is an existing directory name, ln will give each source file a connection with the same file name as the source file in that directory. (for different cases, see the following-- no-dereference

If only two file names are given, ln will generate a connection to the source file; if the last parameter is not a directory name or more than two file names, an error will be reported

By default, ln does not delete existing files or symbolic links. (therefore, it can be used to lock the target file, that is, when dest no longer exists.) but the option-f can be enforced.

In existing implementations, only superusers can establish hard connections to directories. POSIX forbids system calls to link (2) and ln to establish hard connections to directories (but allows hard connections between different file systems).

POSIX option

-f Delete an existing destination file.

GNU option

-d,-F,-- directory

Allow superusers to establish directory hard connections.

-f,-- force

Delete an existing destination file.

-I-- interactive

Prompt whether to delete the existing destination file.

-n,-- no-dereference

When the destination file name given is a symbolic link to a directory, it is treated as a general file.

When the destination directory name is a real directory (not a symbolic link), instead of obfuscating, a connection is established in that directory. But when the specified destination directory name is a symbolic link

There are two ways to deal with user requirements Ln regards the purpose as a normal directory and establishes a connection in it. Or treat it as a non-directory like the symbolic link itself. In this case, ln

The symbolic connection will be deleted or backed up before a new connection is established. By default, symbolic links are treated as normal directories.

-s-- symbolic

Establish a symbolic connection instead of a hard connection. On systems that do not support symbolic connections, this option will only generate an error message.

-v,-- verbose

Displays the file name of the operation before establishing the connection.

GNU backup option

For backing up files that may be overwritten, overwritten, or corrupted, GNU provides commands such as cp, mv, ln, install and patch. You can use the-b parameter to generate backup files. Name of the backup file

Specified by the-V parameter. If the name of the backup file is obtained from the original file name with a suffix, specify this suffix with the-S parameter.

-b,-- backup

Back up the file.

-S SUFFIX,-suffix=SUFFIX

Add "SUFFIX" (your suffix) after backing up the file. If this parameter is not used, the environment variable SIM_PLE_BACHUP_SUFFIX is used, or'~'is used by default if the environment variable is not set.

-V METHOD,-version-control=METHOD

Specifies how the backup file is named. The parameter "METHOD" can be 'numbered' (or' t'), 'existing' (or' nil'), or 'never' (or' simple'). If this parameter is not used, the environment change is used.

Quantity VERSION_CONTROL, if the environment variable is not set, 'existing' is used by default.

The correct and valid METHOD parameter corresponds to the Emacs variable 'version-control'. (the only recognized abbreviation):

T, numbered produces backup files in the form of digital tags.

Nil, existiong digitally back up files that have been backed up with digital tags, while simply backing up other types of files.

Never, simple always makes simple backups.

GNU standard parameters

-help displays usage information on standard output and exits smoothly.

-version

Display version information on standard output and exit smoothly

-- list of terminal parameters.

Environment variable

The variables LANG, LC_ALL, LC_COLLATE, LC_CTYPE and LC_MESSAGES have the usual meaning. In the GNU version, the variables SIMPLE_BACKUP_SUFFIX and VERSION_CONTROL control the naming of backup files.

Follow

POSIX 1003.2, although POSIX 1003.2 (1996) does not discuss soft connections. Soft connections are described in BSD and do not appear in System V release3 (or older) systems.

See also

Ls (1), rm (1), link (2), lstat (2), open (2), readlink (2), stat (2), unlink (2)

Be careful

This article is from the application document-4.0, and there are bound to be slight differences in other versions. For any comments on adding or correcting errors, please send it to: aeb@cwi.nl. Program Bugs, please inform: fileutils-bugs@gnu.ai.mit.edu

[Chinese version of maintainer]

Surran

[the latest update of the Chinese version]

2000-10-19

[China Linux Forum man manual page translation plan]

Http://cmpp.linuxforum.net

GNU fileutils 4.0 November 1998 LN (1)

(END)

-S SUFFIX,-suffix=SUFFIX

Add "SUFFIX" (your suffix) after backing up the file. If this parameter is not used, the environment variable SIM_PLE_BACHUP_SUFFIX is used, or'~'is used by default if the environment variable is not set.

-V METHOD,-version-control=METHOD

Specifies how the backup file is named. The parameter "METHOD" can be 'numbered' (or' t'), 'existing' (or' nil'), or 'never' (or' simple'). If this parameter is not used, the environment change is used.

Quantity VERSION_CONTROL, if the environment variable is not set, 'existing' is used by default.

The correct and valid METHOD parameter corresponds to the Emacs variable 'version-control'. (the only recognized abbreviation):

T, numbered produces backup files in the form of digital tags.

Nil, existiong digitally back up files that have been backed up with digital tags, while simply backing up other types of files.

Never, simple always makes simple backups.

GNU standard parameters

-help displays usage information on standard output and exits smoothly.

-version

Display version information on standard output and exit smoothly

-- list of terminal parameters.

:

-S SUFFIX,-suffix=SUFFIX

Add "SUFFIX" (your suffix) after backing up the file. If this parameter is not used, the environment variable SIM_PLE_BACHUP_SUFFIX is used, or'~'is used by default if the environment variable is not set.

-V METHOD,-version-control=METHOD

Specifies how the backup file is named. The parameter "METHOD" can be 'numbered' (or' t'), 'existing' (or' nil'), or 'never' (or' simple'). If this parameter is not used, the environment change is used.

Quantity VERSION_CONTROL, if the environment variable is not set, 'existing' is used by default.

The correct and valid METHOD parameter corresponds to the Emacs variable 'version-control'. (the only recognized abbreviation):

T, numbered produces backup files in the form of digital tags.

Nil, existiong digitally back up files that have been backed up with digital tags, while simply backing up other types of files.

Never, simple always makes simple backups.

GNU standard parameters

-help displays usage information on standard output and exits smoothly.

-version

Display version information on standard output and exit smoothly

-- list of terminal parameters.

Environment variable

The variables LANG, LC_ALL, LC_COLLATE, LC_CTYPE and LC_MESSAGES have the usual meaning. In the GNU version, the variables SIMPLE_BACKUP_SUFFIX and VERSION_CONTROL control the naming of backup files.

Follow

POSIX 1003.2, although POSIX 1003.2 (1996) does not discuss soft connections. Soft connections are described in BSD and do not appear in System V release3 (or older) systems.

See also

Ls (1), rm (1), link (2), lstat (2), open (2), readlink (2), stat (2), unlink (2)

Be careful

This article is from the application document-4.0, and there are bound to be slight differences in other versions. For any comments on adding or correcting errors, please send us: aeb@cwi.nl. Program Bugs, please inform: fileutils-bugs@gnu.ai.mit.edu

[Chinese version of maintainer]

Surran

[the latest update of the Chinese version]

2000-10-19

[China Linux Forum man manual page translation plan]

Http://cmpp.linuxforum.net

GNU fileutils 4.0 November 1998 LN (1)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report