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

Does linux have an in command?

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "does linux have in command". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "does linux have in orders?"

There is an in command in linux. The in command is used to establish a synchronous link for a file in another location. When using the same file, you only need to put the file in a fixed directory and connect with the in command in other directories. The syntax is "ln [parameters] [source file or directory] [target file or directory]".

The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

Does linux have an in command?

Ln is another very important command in linux. Its function is to establish a synchronous link for a file in another location. When we need to use the same file in a different directory, we don't need to put the same file in every directory we need, we just put the file in a fixed directory, and then link it with the ln command (link) in another directory, without repeatedly occupying disk space.

1. Command format:

Ln [parameter] [source file or directory] [target file or directory]

2. Command function:

Linux file system, there are so-called link, we can regard it as an alias for the file, and links can be divided into two types: hard link (hard link) and soft link (symbolic link), hard link means that an file can have multiple names, while the soft link way is to generate a special file, the content of the file is to point to the location of another file. Hard links exist in the same file system, while soft links can span different file systems.

Soft links:

1. Soft links exist in the form of paths. Similar to shortcuts in the Windows operating system

two。 Soft links can cross file systems, but hard links cannot

3. A soft link can link to a file name that does not exist.

4. Soft links can link directories

Hard links:

1. Hard links, in the form of a copy of the file. But it doesn't take up real space.

two。 Hard links to directories are not allowed

3. Hard links can only be created in the same file system

Here are two points to pay attention to:

First, the ln command keeps the synchronization of every linked file, that is, no matter where you change, the other files will change the same.

Second, ln links are divided into soft links and hard links, soft links are ln-s source file target files, it will only generate an image of a file in the location you choose, will not take up disk space, hard link ln source file target files, no parameter-s, it will generate a file of the same size as the source file in your selected location, whether soft link or hard link The files are kept synchronized.

The ln instruction is used to link files or directories, just as if you specify more than two files or directories, and the final destination is an existing directory, all previously specified files or directories will be copied to that directory. If you specify more than one file or directory at the same time, and the final destination is not an existing directory, an error message appears.

3. Command parameters:

Required parameters:

-b delete, overwrite previously established links

-d allows superusers to make hard links to directories

-f Enforcement

-I interactive mode, the presence of a file prompts the user whether to overwrite

-n treat symbolic links as general directories

-s soft links (symbolic links)

-v shows the detailed process

Select parameters:

-S "- S" or "--suffix="

-V "- V" or "--version-control="

-- help displays help information

-- version displays version information

4. Use an example:

Example 1: create a soft link to a file

Command:

Ln-s log2013.log link2013

Output:

[root@localhost test] # ll-rw-r--r-- 1 root bin 61 11-13 06:03 log2013.log [root@localhost test] # ln-s log2013.log link2013 [root@localhost test] # lllrwxrwxrwx 1 root root 11 12-07 16:01 link2013-> log2013.log-rw-r--r-- 1 root bin 61 11-13 06:03 log2013.log

Description:

Create a soft link link2013 for the log2013.log file. If the log2013.log is lost, the link2013 will fail.

Example 2: create a hard link to a file

Command:

Ln log2013.log ln2013

Output:

[root@localhost test] # lllrwxrwxrwx 1 root root 11 12-07 16:01 link2013-> log2013.log-rw-r--r-- 1 root bin 61 11-13 06:03 log2013.log [root@localhost test] # ln log2013.log ln2013 [root@localhost test] # lllrwxrwxrwx 1 root root 11 12-07 16:01 link2013-> log2013.log-rw-r--r-- 2 root bin 61 11-13 06:03 ln2013-rw-r--r-- 2 Root bin 61 11-13 06:03 log2013.log

Description:

Create a hard link for log2013.log ln2013,log2013.log has the same properties as ln2013

At this point, I believe you have a deeper understanding of "do you have in commands in linux?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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