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

How to use the common command ln in Linux

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article is about how to use the Linux command ln. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

The ln (link files) command is a very important command. Its function is to establish a synchronous link for one file in another location.

Syntax ln [parameter][source file or directory][destination file or directory] where parameter is of the form

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

[–help] [–version] [–]

Command function: Linux file system, there are so-called links (link), we can think of it as an alias of the file, and links can be divided into two types: hard link (hard link) and soft link (symbolic link), hard link means that a file can have multiple names, and 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.

Hard or soft links do not duplicate the original file and take up very little disk space.

Soft Links:

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

2. Soft links can cross file systems, hard links cannot

3. Soft links can link to a file name that does not exist

4. Soft links can link to directories

Hard Links:

1. Hard links exist in the form of copies of files. But it doesn't take up real space.

2. Hard links to directories are not allowed

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

Command Parameters Required Parameters:

-b Delete, overwrite previously established links

-d Allow superusers to make hard links to directories

-f Enforcement

-i Interactive mode, prompt user if file exists

-n Think of symbolic links as general directories

-s soft link (symbolic link)

-v shows detailed processing

Select parameters:

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

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

- help Display help information

- version Displays version information

Example Create soft link for file, create soft link for log2013.log file link2013, if log2013.log is lost, link2013 will be invalid:

ln -logs 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]# ll lrwxrwxrwx 1 root root 11 12-07 16:01 link2013 -> log2013.log -rw-r--r-- 1 root bin 61 11-13 06:03 log2013.log Create a hard link to the file, create a hard link to log2013.log ln2013, log2013.log has the same attributes as ln2013

ln log2013.log ln2013 Output:

[root@localhost test]# ll lrwxrwxrwx 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]# ll lrwxrwxrwx 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 00:01:01 Thank you for reading this! About "Linux common command ln how to use" this article is shared here, I hope the above content can have some help for everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!

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

Development

Wechat

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

12
Report