1: How do I find large files?
Search for files in the current directory that are larger than 100M in size:
[[email protected] u03]# find . -type f -size +100m./usr/local/ jdk-7u67-linux-x64.tar.gz./data/log/charge-service/test-access.log.2016-08-08.log./data/log/aaa_service/ test-access.log.2016-08-09.log./home/deploy/logs/testmqlogs/otherdays/testmq_client.1.log./home/deploy/logs/ testmqlogs/otherdays/testmq_client.2.log./opt/backend/charge-service/1.2/shared/console.log./opt/backend/ Express_service/0.0.3.tar.gz./opt/backend/aaa-service/1.2/shared/console.log
[[Email protected] u03]# find . -type f -size +100m -print0 | xargs -0 ls -l-rw-rw-r-- 1 deploy deploy 542795006 8 Month 30 15:14 ./data/log/charge-service/test-access.log.2016-08-08.log-rw-rw-r-- 1 Deploy deploy 225658142 8 Month 25 16:28 ./data/log/aaa_service/ Test-access.log.2016-08-09.log-rw-rw-r-- 1 deploy deploy 253623621 8 Month 30 15:15 ./home/deploy/logs/testmqlogs/otherdays/testmq_client.1.log-rw-rw-r-- 1 deploy deploy 373547598 8 Month 25 16:28 ./home/deploy/logs/testmqlogs/otherdays/ Testmq_client.2.log-rw-rw-r-- 1 deploy deploy 645631934 8 Month 30 15:15 ./opt/backend/charge-service/1.2/shared/console.log-rw-rw-r-- 1 deploy deploy 209314900 8 Month 30 15:15 ./opt/backend/aaa-service/1.2/shared/console.log-rw-r--r-- 1 root root 315334884 12 Month 21 2015 ./opt/backend/express_service/0.0.3.tar.gz-rw-r--r-- 1 root root 142376665 6 Month 11 2015 ./usr/local/ Jdk-7u67-linux-x64.tar.gz-rw-rw-r-- 1 deploy deploy 105085974 8 Month 30 15:15 ./usr/local/push-tomcat/logs/push/info.log6829699375703641.tmp
when we just need to look for more than 100M size file and show the exact size of the found file, and sort (bottom)
[[Email protected] u03]# find . -type f -size +100m -print0 | xargs -0 du -h102m ./usr/local/push-tomcat/logs/push/ info.log6829699375703641.tmp136m ./usr/local/jdk-7u67-linux-x64.tar.gz518m . /data/log/charge-service/test-access.log.2016-08-08.log216m ./data/log/aaa_service/ Test-access.log.2016-08-09.log242m ./home/deploy/logs/testmqlogs/otherdays/testmq_ client.1.log357m ./home/deploy/logs/testmqlogs/otherdays/testmq_client.2.log616m ./opt/backend/charge-service/1.2/shared/console.log301m ./opt/backend/express_service/ 0.0.3.tar.gz201m ./opt/backend/aaa-service/1.2/shared/console.log
[[email protected] u03]# find . -type f -size +100m - print0 | xargs -0 du -h | sort -nr616m ./opt/backend/ charge-service/1.2/shared/console.log518m ./data/log/charge-service/ Test-access.log.2016-08-08.log357m ./home/deploy/logs/testmqlogs/otherdays/testmq_ client.2.log301m ./opt/backend/express_service/0.0.3.tar.gz243m ./home/ deploy/logs/testmqlogs/otherdays/testmq_client.1.log216m ./data/log/aaa_service/ Test-access.log.2016-08-09.log201m ./opt/backend/aaa-service/1.2/shared/console.log
However, as shown above, sometimes the order is not exactly the same size, this is due to the parameter H of the du command, you can use the unified use of MB to display, this will solve the problem. Here, the command to find large files in the Linux system is perfect, but if you have a lot of needs, you can make changes and adjustments on this command.
2: How to find a large directory under Linux
For example, sometimes disk space alarm, and you usually neglect to manage, monitor the growth of files, then I need to quickly understand which directories become larger, then we can use the du command to help us solve this problem.
[Email protected] u03]# du-h--max-depth=116k/lost+found33g./flash_recovery_area37g./oradata70g. If you If you want to know what big folders are under the Flash_recovery_area directory, then you can max-depth=2 the parameters, and if you want to sort the results of the search, you can use the sort command. As shown below
[[email protected] u03]# du -h --max-depth=2 | sort -n3.5g ./flash_recovery_area/EPPS16K ./lost+found29G ./flash_recovery_area/backup33G ./flash_recovery_area37G ./oradata37g ./oradata/epps70g . [[email protected] u03]# du -hm --max-depth=2 | sort -n1 ./lost+found3527 ./flash_recovery_area/EPPS29544 ./flash_recovery_area/backup33070 ./flash_recovery_area37705 ./ oradata37705 ./oradata/epps70775 .
Sometimes the search results are too many (for example, I start from the root directory search), has been in the brush screen, if I only want to find out the largest 12 folders, how to do? At this point, the Head command is used to display the
[[email protected] /]# du -hm --max-depth=2 | sort -nr | head -12407480 .167880 ./u04158685 ./u02/oradata158685 ./ u02152118 ./u04/oradata70775 ./u0337705 ./u03/oradata33070 ./u03/flash_recovery_area5995 ./u01/app5995 ./ U013551 ./usr1558 ./usr/share
Resources:
http://linuxandfriends.com/how-to-find-large-files-in-linux-using-command-line/
Http://www.docin.com/p-563963500.html
This article is from the "It Struggle" blog, please be sure to keep this source http://qiangsh.blog.51cto.com/3510397/1844338
How Linux finds large files or directory summaries