In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to use the ln command in linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Full name
The full name of ln is link, as the name implies, this is a build a link. How to understand it? Its function is similar to the alias of Mac OS or the shortcut of Windows, and deletion does not affect the file itself.
Description: (just look at italics directly)
There are two types of links: hard links (hard link) and soft links (symbolic link)
Regardless of the type of link, it provides a means of two-way reference-that is, no matter which name you modify the content of the file, the effect of your modification will be reflected in the file with the original name. it will also be reflected in the file with the link name. When you work at a higher level, the difference between soft and hard links will occur. Hard chain
The next advantage is that the original file and the linked file are independent of each other-if you delete or rename the old file, then this operation will not affect the hard-linked file, the hard-linked file is still the content of the original file.
However, if you use a soft link, when you delete or rename the old file, the soft link will no longer find the contents of the original file. The advantage of a soft link is that it can span the file system (because it is just a reference to the file name, not real data). Another difference from hard links is that a symbolic link can point to a
Catalogue.
Example:
1.$ln file.txt file.copy
File.copy is a shortcut to file.txt.
View-help
The code is as follows:
Usage: ln [option]. [- T] Target link name (first format)
Or: ln [options]... Target (second format)
Or: ln [options]... The target. Table of contents (third format)
Or: ln [options]... -t directory target. (fourth format)
In the first format, the specified name is created and the link to the specified destination is created.
In the second format, a link to the target location is created in the current directory.
In the third and fourth formats, create a link to the specified destination in the specified directory.
Create hard links by default and symbolic links when using-- symbolic.
Each specified target must exist when creating a hard link. Symbolic links can point to any location
When the link resolution is normal, resolve it to a link associated with its parent directory.
The parameters that must be used for long options are also required for short options.
-- backup [= CONTROL] creates a backup file for each existing target file
-b is similar to-- backup, but does not accept any parameters
-d,-F,-- directory creates a hard link to a directory (for superusers only)
-f,-- force forcibly overwrites any existing linked files
-I,-- interactive confirm before overwriting the linked file
-L,-- logical creates hard links as symbolic link references
-n,-- no-dereference if the destination is a symbolic link to a directory, the
The symbolic link is treated as an ordinary file, first treating the existing chain
Pick up backup or overwrite
-s,-- symbolic creates symbolic links (soft links) instead of hard links
-S,-- suffix= suffix specifies the suffix of the linked file
-t,-- target-directory= directory creates links in the specified directory
-T,-- no-target-directory treats the link name as a normal file
-v,-- print relevant information before verbose link
-- help displays this help and exits
-- version displays version information and exits
Backup files are suffixed with "~" unless with the-- suffix option or SIMPLE_BACKUP_SUFFIX
Environment variable assignment. Version control can be done through the-- backup option or the VERSION_CONTROL environment
Variable to select. The following are the available variable values:
Using the-s option ignores-L and-P.
Otherwise, when the source is a symbolic link (default-P), the behavior will be controlled by the last option specified.
None, off does not backup (even if the-- backup option is used)
Numbered, t backup files are sorted with numbers
Existing, nil use numbers if digital backup files already exist, otherwise backup by normal method
Simple, never always back up in the normal way
Interpretation:
1-s
Create a soft link ln-s file.txt / ${dir} / file.copy
2.-f-b
-f actually forcibly overwrites existing hard links (Note: some ubuntu translations are incorrect)
-b refers to pre-overwrite backup
3.-I
Ask questions before overwriting the file
4.-S
It is essentially different from-S. no, no, no. Here is a suffix for him (it may be an extension in window, but this is not the way to distinguish files in linux)
Actual combat:
1. Now I need to configure jdk,tomcat, and there are multiple nodes, and some configuration files are in different directories. Sometimes, some remote toolsets are used. Working time is a little long, slowly found a lot of time in the switching directory, so, I put all the shortcuts, all centralized a few folders, and classified, and then some simple operations remote or shared, in the win operation.
two。 Establish a soft link
$ln-s file.txt / ${dir} /
3. You can use the suffix to indicate that the file is a soft connection
$ln-s file.txt / ${dir} / file-v-S.url
-v prompts for file changes,-S.url indicates the suffix name of file-s indicates a soft connection
4. If you always encounter a lot of similar names, you need to be prompted before overwriting.
Do not prompt before overwriting $ln-f
$ln-I overrides the prompt before
Chinese introduction
Usage: ln [option]. [- T] destination link name (first format) or: ln [option]. Target (second format) or: ln [options]. The target. Directory (third format) or: ln [options]. -t directory target. (fourth format) in the first format, the specified name is created and the link to the specified destination is created. In the second format, a link to the target location is created in the current directory. In the third and fourth formats, create a link to the specified destination in the specified directory. Create hard links by default and symbolic links when using-- symbolic. Each specified target must exist when creating a hard link. A symbolic link can point to any location, and when the link parses normally, it is resolved into a link associated with its parent directory. The parameters that must be used for long options are also required for short options. -- backup [= CONTROL] creates a backup file for each existing target file-b similar to-- backup But do not accept any parameters-d,-F,-- directory create a hard link to the directory (only for superusers)-f,-- force forcibly delete any existing target files-I,-- interactive confirm before deleting the file-L -- logical creates a hard link as a symbolic link reference-n,-- no-dereference if the destination is a symbolic link to a directory The symbolic link will be treated as a normal file First back up or delete the existing link-s,-- symbolic creates a symbolic link instead of a hard link-S,-- suffix= suffix specifies the suffix of the backup file-t,-- target-directory= directory creates a link-T in the specified directory. -- no-target-directory treats the link name as a normal file-v,-- lists the name of each file before the verbose link-- help displays this help and exits-- version displays version information and exits the backup file with the suffix "~" Unless specified with the-- suffix option or the SIMPLE_BACKUP_SUFFIX environment variable. The method of version control can be selected through the-- backup option or the VERSION_CONTROL environment variable. The following are the available variable values: using the-s option ignores-L and-P. Otherwise, when the source is a symbolic link (default-P), the behavior will be controlled by the last option specified. None, off do not backup (even if the-backup option is used) numbered, t backup files plus numbers to sort existing, nil if there are digital backup files already exist, use numbers, otherwise use the normal way to back up simple, never always uses the normal way to back up all the contents of the article "how to use the ln command in linux", thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.