Add links and delete links under Linux (the use of the LN command)

Source: Internet
Author: User
Tags directory create jboss

adding links using the ln command
Usage:
#ln--help
Usage: ln [options] ... Target [link name]
Or: ln [options] ... Goal... Directory
Or: ln [options] ...--target-directory= directory target ...
Create a link to a specified < target > and optionally specify < link name >.
If no < link name is specified, a link to the < target > name is created in the current directory.
When using the second format < target > More than one, the final argument must be the directory;
< directory > links to each < target > are created separately. The default is to create a hard link if
Use the--symbolic option to create symbolic links. When you create a hard link, each < target > must be saved
In.

The parameters that must be used for the long option are also required when using the short option.
--backup[=control] Make a backup of each existing destination file
-B like--backup but does don't accept an argument
-D,-F,--directory allow the superuser to attempt-hard link
Directories (Note:will probably fail due to
System restrictions, even for the superuser)
-F,--force remove existing destination files
-N,--no-dereference if the destination is a symbolic link to a directory, the
The symbolic link is treated as a generic file, first the existing
Link Backup or delete
-I,--interactive confirm whether to delete destination file
-S,--symbolic create symbolic links instead of hard links
-S,--suffix= suffix self-specified backup file < suffix >
--target-directory= Directory Create links in specify < directory >
-V,--verbose the name of each file before linking
--HELP Display this help message and leave
--version display version information and leave

The suffix of the backup file is ' ~ ' unless the--suffix option is selected or Simple_backup_suffix
The environment variable is specified. Version control is available through the--backup option or the Version_control environment
Variable to select. The following are the available variable values:

None, off is not backed up (even with the--backup option)
Numbered, the T backup file is prefixed with a number
Existing, nil if a digital backup file already exists, use a number, otherwise use the normal way to back up
Simple, never always use normal way to back up

When you delete a link, use the RM command directly


Example:

Add to
Ln-s/usr/jboss4.0.5.ga/jboss

Delete
RM JBoss Reference: 1. How to use: ln [option] source_file Dist_file (source_file is the file to be established for the linked file, Dist_file is the newly created link file)
-F is created, it is deleted with the file name.
-I ask before deleting.
LN-S ABC CDE establishes the soft connection of ABC
LN ABC CDE establishes the hard connection of ABC,

2. The difference between soft links and hard links (popular):
A hard link can be considered to be a file with two filenames; The soft link is the system creates a new link file, which points to the file it refers to. In addition, soft links can be made to files and folders. Hard links are only for files.

3. The difference between soft links and hard links (explained):
Linux soft and hard connections for a file, there is a unique index point corresponding to it, and for an index contact number, you can have multiple filenames corresponding to it. Therefore, the same file on the disk can access the file through a different path. Note that under Linux everything is file, folder, new HDD ... Can look at the file to deal with AH.
A soft connection (symbolic link) is also called a symbolic connection, connected with a soft connection and a hard link. Symbolic connections are equivalent to shortcuts under Windows.
It is not possible to make hard connections to folders, we usually use more soft connections.

eg
Ln-s Source Dist # establishing a soft connection
ln Source Dist # to establish a hard connection


Soft link is actually just a piece of text, which contains the name of the file it points to, the system sees the soft link automatically jumps to the corresponding file location for processing; instead, a hard join opens a new directory entry for the file, and the hard links and the original names of the files are equal, and in Linux it appears to be equivalent. For this reason, a hard link cannot connect files on two different file systems.
(1) Soft connection can cross file system, hard connection is not possible. The practice is to use shared files to connect aa.txt text documents under Windows to Linux under the/root directory BB,CC. Ln-s Aa.txt/root/bb Connection succeeded. ln aa.txt/root/bb failed. (2) Questions about the I node. Hard connections No matter how many, all point to the same I node, will increase the number of node connections, as long as the junction number of connections is not 0, the file exists, regardless of whether you delete the source file or the connected file. As long as there is one exists, the file exists (in fact, it does not divide the source file connection files, because they point to the same I node). When you modify the source file or any one of the connection files, the other files will be changed synchronously. Soft links do not use the I node number directly as a file pointer, but instead use the file path masterpiece as a pointer. Therefore, deleting a connection file has no effect on the source file, but deleting the source file will cause the connection file to be unable to find the file to point to. The soft link has its own inode, and there is a small space on the disk to store the path name.
(3) A soft connection can be connected to a file name that does not exist.
(4) The soft connection can be connected to the directory. finally delete the symbolic link, there is the deletion of the creation RM-RF symbolic_name Note not rm-rf symbolic_name/

Add links and delete links under Linux (the use of the LN command)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.