In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to use the ln command in linux". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn how to use the ln command in linux.
Linux ln command
As you now know, the ln command allows you to create links between files. Here is the syntax of the ln tool (or use some other syntax that works).
Ln [OPTION]... [- T] TARGET LINK_NAME (* *) ln [OPTION]. TARGET (second form) ln [OPTION]. TARGET... DIRECTORY (the third form) ln [OPTION]. -t DIRECTORY TARGET... (fourth form)
The following is what the ln tool man documentation describes:
In the form of * *, create a link called LINK_NAME for the target location (TARGET). In the second form, a link is created under the current directory for the target location (TARGET). The LCTT is created as a link with the same name. In the third and fourth forms, links are created for each target location (TARGET) under the DIRECTORY directory. Hard links are created by default, and symbolic links require the-- symbolic option. Each created link (the name of the new link) created by default cannot already exist. When you create a hard link, the target location (TARGET) file must exist; the symbolic link can save any text, and if it is resolved later, the resolution of the relative link is related to its parent directory.
The following example of Q & A style may give you a better understanding. But before that, it is recommended that you first understand the difference between hard links and soft links.
Q1. How do I create hard links using the ln command?
It's simple, you just need to use the ln command like this:
Ln [file] [hard-link-to-file]
For example:
Ln test.txt test_hard_link.txt
How to create hard links using the ln command
In this way, you can see a hard link called test_hard_link.txt that has been created.
Q2. How do I create soft / symbolic links using the ln command?
Use the-s command line option:
Ln-s [file] [soft-link-to-file]
For example:
Ln-s test.txt test_soft_link.txt
How to create soft / symbolic links using the ln command
The test_soft_link.txt file is a soft / symbolic link marked with sky blue text.
Q3. How do I delete an existing object file with the same name using the ln command?
By default, ln does not allow you to create existing links in the target directory.
Example of ln command
However, if you have to, you can override this behavior with the-f command line option.
How to create soft / symbolic links using the ln command
Tip: if you want to interact during this deletion, you can use the-I option.
Q4. How do I use the ln command to create a backup of an existing file with the same name?
If you do not want ln to delete existing files with the same name, you can create backups of those files. You can achieve this effect with-b, and backup files created in this way include a tilde (~) at the end of their file names.
How to use the ln command to create a backup of an existing file with the same name
Q5. How do I create a link in a directory other than the current directory?
Use the-t option to specify a file directory (except the current directory). For example:
Ls test* | xargs ln-s-t / home/himanshu/Desktop/
The above command creates links for all test* files (in the current directory) and places them in the desktop directory.
The above is all the contents of the article "how to use ln commands 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.