In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
What are the three methods of finding files on Linux? I believe many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Sometimes we install dozens of applications on the system.
The first kind: ls
The easiest way is to use the ls command, because the ls command itself outputs with file size information.
For example, I want to list the five largest files in the / bin directory, you can:
Ls-lSh / bin | head-5
The second kind: find
Find itself is a search command, and you can recursively find a subdirectory of a directory, so it's natural to use it.
For example, find the largest file in the / directory:
Sudo find /-type f-printf "% s\ t% p\ n" | sort-n | tail-1
If you want to find the top 10 large files, you can do this:
$find $HOME-type f-printf'% s% p\ n'| sort-nr | head-10
You can also use the-size option to find it, and the following command displays all files greater than 100MiB (note that it is not the difference between 100MB MIB and MB, emmm):
Find /-size + 100M-ls
You can also find a file between an interval size (such as 100MiB and 200MiB):
Find /-size + 100M-size-200M-ls
Finally, the following command is also commonly used to find the five largest files in a directory:
Find $DIRECTORY-type f-exec ls-s {}\; | sort-n | tail-n 5
In addition, find can also find the most recent files: files less than or equal to n days (- ctime-n) or files belonging to a specific user (- user mrlinus).
The third kind: du
The du command can be used to view disk space usage, and naturally it can also be used to view files and folders that take up more space on disk.
For example, look for the top 20 largest files under / home:
Sudo du-a / home | sort-n-r | head-n 20
Find the top 10 directories in the current folder:
Sudo du-a | sort-n-r | head-n 10
If you want to display readable KB, MB, GB information, you can add the-h parameter:
Du-hs * | sort-rh | head-n 10
Find the largest directory / file (including subfolders):
Du-Sh | sort-rh | head-n 10
If you only look at all files that are within the size of GB, you can use both the du command and the grep command:
Du-h-a / dir | grep "[0-9] G\ b"
OK, these are the three ways to find large files on Linux systems.
What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.
After reading the above, have you mastered what are the three ways to find files on Linux? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.