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 find the same file under Linux

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

Share

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

Editor to share with you how to find the same file under 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!

Inode is a data structure that records all the information about a file, except for the file name and file contents. If two or more files have the same inode value, even if their file names are different and their locations are different, their contents, owners, and permissions are actually the same, we can treat them as the same file.

This type of file is actually the so-called "hard link". Hard links have the same inode value, but different file names. A soft link is actually a shortcut that points to the target file but has its own inode value.

$ls-l my*-rw-r--r-- 4 liangxu liangxu 228 Apr 12 19:37 myfile lrwxrwxrwx 1 liangxu liangxu 6 Apr 15 11:18 myref-> myfile-rw-r--r-- 4 liangxu liangxu 228 Apr 12 19:37 mytwin

We can't directly know which files in the same directory have the same inode value, but it's not difficult to identify them. In fact, we just need to use the ls-I command, and then sort by the inode value, we can find these files directly.

$ls-I | sort-n | more... 788000 myfile / dev/null 788000 4-rw-r--r-- 4 liangxu liangxu 228 Apr 12 19:37 / tmp/mycopy 788000 4-rw-r--r-- 4 liangxu liangxu 228 Apr 12 19:37 / home/liangxu/myfile 788000 4-rw-r--r-- 4 liangxu liangxu 228 Apr 12 19:37 / home/liangxu/save/mycopy 788000 4-rw-r -- rmur4 liangxu liangxu 228 Apr 12 19:37 / home/liangxu/mytwin

In this command, we redirect the error prompt to the special file / dev/null, so that when searching for paths that we don't have permission to access, there will not be a full screen of permission denied.

The above is all the contents of the article "how to find the same File under 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.

Share To

Servers

Wechat

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

12
Report