In the Windows system, we can use the TreeSize tool to find some large files or folders, very convenient and efficient, in the Linux system, how to search for some of the larger files? Now I've sorted out how to find large files or folders on a Linux system.
1: How do I find large files?
In fact, many times, you need to know what the current system under the large files, such as the file size of more than 100M or 1G (threshold value depending on the situation). So how do you search for these big files? For example, I want to search for files that are larger than 800M in the current directory
[Email protected] u03]# pwd
/u03
[[email protected] u03]# find. -type f-size +800m
./flash_recovery_area/backup/backupsets/ora_df873519197_s46815_s1
./flash_recovery_area/backup/backupsets/ora_df873523646_s46822_s1
./flash_recovery_area/backup/backupsets/ora_df873521714_s46818_s1
./flash_recovery_area/backup/backupsets/ora_df873522876_s46820_s1
./flash_recovery_area/backup/backupsets/ora_df873517396_s46813_s1
./flash_recovery_area/backup/backupsets/ora_df873523321_s46821_s1
./flash_recovery_area/backup/backupsets/ora_df873515765_s46811_s1
./flash_recovery_area/backup/backupsets/ora_df873520789_s46817_s1
./flash_recovery_area/backup/backupsets/ora_df873524162_s46823_s1
./flash_recovery_area/backup/backupsets/ora_df873518302_s46814_s1
./flash_recovery_area/backup/backupsets/ora_df873519953_s46816_s1
./flash_recovery_area/backup/backupsets/ora_df873516500_s46812_s1
./flash_recovery_area/backup/backupsets/ora_df873513413_s46809_s1
./flash_recovery_area/backup/backupsets/ora_df873514789_s46810_s1
./oradata/epps/invsubmat_d08.dbf
./oradata/epps/gmtinv_d08.dbf
./oradata/epps/gmtinv_x01.dbf
./oradata/epps/undotbs02.dbf
./oradata/epps/gmtinv_d07.dbf
./oradata/epps/undotbs01.dbf
./oradata/epps/gmtinv_x02.dbf
As shown in the command above, we can only see the file name of files over 800M, but the information about the file (for example, file size, file attributes) is unknown, can you show some file attributes or information in more detail, of course, as shown below
[[email protected] u03]# find. -type F-size +800m-print0 | xargs-0 ls-l
-RW-R-----1 Oracle Oinstall 2782846976 Mar 6 11:51./flash_recovery_area/backup/backupsets/ora_df873513413_s46809_s1
-RW-R-----1 Oracle Oinstall 1878433792 Mar 6 11:53./flash_recovery_area/backup/backupsets/ora_df873514789_s46810_s1
-RW-R-----1 Oracle Oinstall 1378492416 Mar 6 11:54./flash_recovery_area/backup/backupsets/ora_df873515765_s46811_s1
-RW-R-----1 Oracle Oinstall 1641381888 Mar 6 11:56./flash_recovery_area/backup/backupsets/ora_df873516500_s46812_s1
-RW-R-----1 Oracle Oinstall 1564065792 Mar 6 11:58./flash_recovery_area/backup/backupsets/ora_df873517396_s46813_s1
-RW-R-----1 Oracle Oinstall 1663492096 Mar 6./flash_recovery_area/backup/backupsets/ora_df873518302_s46814_s1
-RW-R-----1 Oracle Oinstall 1368244224 Mar 6 12:02./flash_recovery_area/backup/backupsets/ora_df873519197_s46815_s1
-RW-R-----1 Oracle Oinstall 1629069312 Mar 6 12:04./flash_recovery_area/backup/backupsets/ora_df873519953_s46816_s1
-RW-R-----1 Oracle Oinstall 1629954048 Mar 6 12:06./flash_recovery_area/backup/backupsets/ora_df873520789_s46817_s1
-RW-R-----1 Oracle Oinstall 1202192384 Mar 6 12:07./flash_recovery_area/backup/backupsets/ora_df873521714_s46818_s1
-RW-R-----1 Oracle Oinstall 1189388288 Mar 6 12:10./flash_recovery_area/backup/backupsets/ora_df873522876_s46820_s1
-RW-R-----1 Oracle Oinstall 1089257472 Mar 6 12:11./flash_recovery_area/backup/backupsets/ora_df873523321_s46821_s1
-RW-R-----1 Oracle Oinstall 1097687040 Mar 6 12:12./flash_recovery_area/backup/backupsets/ora_df873523646_s46822_s1
-RW-R-----1 Oracle Oinstall 1051009024 Mar 6 12:13./flash_recovery_area/backup/backupsets/ora_df873524162_s46823_s1
-RW-R-----1 Oracle Oinstall 4294975488 APR 3 15:07./oradata/epps/gmtinv_d07.dbf
-RW-R-----1 Oracle Oinstall 4194312192 APR 1 22:36./oradata/epps/gmtinv_d08.dbf
-RW-R-----1 Oracle Oinstall 4294975488 APR 3 15:54./oradata/epps/gmtinv_x01.dbf
-RW-R-----1 Oracle Oinstall 4294975488 APR 3 15:57./oradata/epps/gmtinv_x02.dbf
-RW-R-----1 Oracle Oinstall 4294975488 APR 1 22:35./oradata/epps/invsubmat_d08.dbf
-RW-R-----1 Oracle Oinstall 8589942784 APR 4 09:55./oradata/epps/undotbs01.dbf
-RW-R-----1 Oracle Oinstall 8589942784 APR 4 09:15./oradata/epps/undotbs02.dbf
When we only need to find files larger than 800M size and display the exact size of the found file, you can use the following command
[[email protected] u03]# find. -type F-size +800m-print0 | xargs-0 du-h
1.3G./flash_recovery_area/backup/backupsets/ora_df873519197_s46815_s1
1.1G./flash_recovery_area/backup/backupsets/ora_df873523646_s46822_s1
1.2G./flash_recovery_area/backup/backupsets/ora_df873521714_s46818_s1
1.2G./flash_recovery_area/backup/backupsets/ora_df873522876_s46820_s1
1.5G./flash_recovery_area/backup/backupsets/ora_df873517396_s46813_s1
1.1G./flash_recovery_area/backup/backupsets/ora_df873523321_s46821_s1
1.3G./flash_recovery_area/backup/backupsets/ora_df873515765_s46811_s1
1.6G./flash_recovery_area/backup/backupsets/ora_df873520789_s46817_s1
1004M./flash_recovery_area/backup/backupsets/ora_df873524162_s46823_s1
1.6G./flash_recovery_area/backup/backupsets/ora_df873518302_s46814_s1
1.6G./flash_recovery_area/backup/backupsets/ora_df873519953_s46816_s1
1.6G./flash_recovery_area/backup/backupsets/ora_df873516500_s46812_s1
2.6G./flash_recovery_area/backup/backupsets/ora_df873513413_s46809_s1
1.8G./flash_recovery_area/backup/backupsets/ora_df873514789_s46810_s1
4.1G./oradata/epps/invsubmat_d08.dbf
4.0G./oradata/epps/gmtinv_d08.dbf
4.1G./oradata/epps/gmtinv_x01.dbf
8.1G./oradata/epps/undotbs02.dbf
4.1G./oradata/epps/gmtinv_d07.dbf
8.1G./oradata/epps/undotbs01.dbf
4.1G./oradata/epps/gmtinv_x02.dbf
If you also need to sort the results by file size, you can use the following command
[[email protected] u03]# find. -type F-size +800m-print0 | xargs-0 Du-h | Sort-nr
1004M./flash_recovery_area/backup/backupsets/ora_df873524162_s46823_s1
8.1G./oradata/epps/undotbs02.dbf
8.1G./oradata/epps/undotbs01.dbf
4.1G./oradata/epps/invsubmat_d08.dbf
4.1G./oradata/epps/gmtinv_x02.dbf
4.1G./oradata/epps/gmtinv_x01.dbf
4.1G./oradata/epps/gmtinv_d07.dbf
4.0G./oradata/epps/gmtinv_d08.dbf
2.6G./flash_recovery_area/backup/backupsets/ora_df873513413_s46809_s1
1.8G./flash_recovery_area/backup/backupsets/ora_df873514789_s46810_s1
1.6G./flash_recovery_area/backup/backupsets/ora_df873520789_s46817_s1
1.6G./flash_recovery_area/backup/backupsets/ora_df873519953_s46816_s1
1.6G./flash_recovery_area/backup/backupsets/ora_df873518302_s46814_s1
1.6G./flash_recovery_area/backup/backupsets/ora_df873516500_s46812_s1
1.5G./flash_recovery_area/backup/backupsets/ora_df873517396_s46813_s1
1.3G./flash_recovery_area/backup/backupsets/ora_df873519197_s46815_s1
1.3G./flash_recovery_area/backup/backupsets/ora_df873515765_s46811_s1
1.2G./flash_recovery_area/backup/backupsets/ora_df873522876_s46820_s1
1.2G./flash_recovery_area/backup/backupsets/ora_df873521714_s46818_s1
1.1G./flash_recovery_area/backup/backupsets/ora_df873523646_s46822_s1
1.1G./flash_recovery_area/backup/backupsets/ora_df873523321_s46821_s1
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=1
16K./lost+found
33G./flash_recovery_area
37G./oradata
70G.
If you want to know which large folders are under the Flash_recovery_area directory, 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-n
3.5G./flash_recovery_area/epps
16K./lost+found
29G./flash_recovery_area/backup
33G./flash_recovery_area
37G./oradata
37G./oradata/epps
70G.
[Email protected] u03]# DU-HM--max-depth=2 | Sort-n
1./lost+found
3527./flash_recovery_area/epps
29544./flash_recovery_area/backup
33070./flash_recovery_area
37705./oradata
37705./oradata/epps
70775.
[[Email protected] u03]# CD/
[Email protected]/]# DU-HM--max-depth=2 | Sort-n
Sometimes search out too many results (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 will be used to display
[Email protected]/]# DU-HM--max-depth=2 | Sort-nr | Head-12
407480.
167880./u04
158685./u02/oradata
158685./u02
152118./u04/oradata
70775./u03
37705./u03/oradata
33070./u03/flash_recovery_area
5995./u01/app
5995./u01
3551./usr
1558./usr/share
Resources:
http://linuxandfriends.com/how-to-find-large-files-in-linux-using-command-line/
Http://www.docin.com/p-563963500.html
How to find large files under CentOS