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-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces how to find the same file under Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

With the use of computers, a lot of garbage will be generated in the system. Typically, the same file is saved to different locations. As a result, disk space is occupied massively, and the system runs more and more slowly.

So if your computer space is in a hurry, you can try to delete such files and free up some space. Under Linux, we can find the same file in the system by identifying the inode value of the file.

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.

Thank you for reading this article carefully. I hope the article "how to find the same documents under Linux" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you 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