Linux如何查找大文件或目录总结

转载:http://www.cnblogs.com/kerrycode/p/4391859.html

在Windows系统中,我们可以使用TreeSize工具查找一些大文件或文件夹,非常的方便高效,在Linux系统中,如何去搜索一些比较大的文件呢?下面我整理了一下在Linux系统中如何查找大文件或文件夹的方法。

 

1: 如何查找大文件?

其实很多时候,你需要了解当前系统下有哪些大文件,比如文件大小超过100M或1G(阀值视具体情况而定)。那么如何把这些大文件搜索出来呢?例如我要搜索当前目录下,超过800M大小的文件

[root@getlnx01 u03]# pwd
/u03
[root@getlnx01 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

clip_image001

 

如上命令所示,我们仅仅能看到超过800M大小的文件的文件名称,但是对文件的信息(例如,文件大小、文件属性)一无所知,那么能否更详细显示一些文件属性或信息呢,当然可以,如下所示

[root@getlnx01 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 12:00 ./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

clip_image002

当我们只需要查找超过800M大小文件,并显示查找出来文件的具体大小,可以使用下面命令

[root@getlnx01 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

clip_image003

 

如果你还需要对查找结果按照文件大小做一个排序,那么可以使用下面命令

[root@getlnx01 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

clip_image004

不过如上截图所示,有时候排列的顺序并不完全是按大小一致,这个是因为du命令的参数h所致,你可以统一使用使用MB来显示,这样就能解决这个问题。到这里,这个在Linux系统查找大文件的命令已经非常完美了,当然如果你还有很多的需求,那么可以在这个命令上做修改、调整.

clip_image005

 

2: 如何查找Linux下的大目录

譬如有时候磁盘空间告警了,而你平时又疏于管理、监控文件的增长,那么我需要快速的了解哪些目录变得比较大,那么此时我们可以借助du命令来帮我们解决这个问题。

[root@getlnx01 u03]# du -h --max-depth=1
16K     ./lost+found
33G     ./flash_recovery_area
37G     ./oradata
70G     .

如果你想知道flash_recovery_area目录下面有哪些大文件夹,那么可以将参数max-depth=2 ,如果你想对搜索出来的结果进行排序,那么可以借助于sort命令。如下所示

[root@getlnx01 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     .
[root@getlnx01 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   .

clip_image006

[root@getlnx01 u03]# cd /

[root@getlnx01 /]# du -hm --max-depth=2 | sort -n

有时候搜索出来的结果太多了(譬如,我从根目录开始搜索),一直在刷屏,如果我只想查出最大的12个文件夹,怎么办呢?此时就要借助head命令来显示了

[root@getlnx01 /]# 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
[root@getlnx01 /]# 

clip_image007

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541858.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

java需要会的工具_Java开发者必备的几款工具,一定要掌握!

原标题:Java开发者必备的几款工具,一定要掌握!NotepadNotepad是用于编辑xml、脚本以及记笔记的最佳工具。这个工具的最好部分在于,你在Notepad上打开的任何一个文档,在关闭后都会有一个残留文档,它有助于在…

Android推荐的几本书

2019独角兽企业重金招聘Python工程师标准>>> 第一阶段 <<第一行代码Android>><<疯狂Android>>第二阶段 <<Android开发艺术探索>><<Android群英传>>Android源码 第三阶段 <<Android开发艺术探索>><&…

tdr上升时间什么设定_TDR的完整形式是什么?

tdr上升时间什么设定TDR&#xff1a;时域反射仪/车票寄存收据/定期存款收据 (TDR: Time Domain Reflectometer/ Ticket Deposit Receipt/ Term Deposit Receipt) 1)TDR&#xff1a;时域反射仪 (1) TDR: Time Domain Reflectometer) TDR is an abbreviation of the "Time D…

【java】反射+poi 导出excel

2019独角兽企业重金招聘Python工程师标准>>> 反射 导出的数组转变成对象 private static Object expexcelMaptobean(Class<?> cobj,Map<String,String> map,int[] expColums,String[] params) throws InstantiationException, IllegalAccessException…

css设置背景图片大小_如何使用CSS设置背景图片大小?

css设置背景图片大小Introduction: 介绍&#xff1a; As we all know that the images are a very responsive yet very creative way to display your web page or website to the users. The images also play a major role in indulging users to websites or web pages. T…

avr计数_使用8位LCD创建计数器| AVR

avr计数This type of counter may be also used in the EVM machines. A counter can be used to count the number of times a button is pressed. It can have many applications. The most widely used counter application is in EVM and also in customer feedback machin…

php将字符变为数字,数字字符怎么转化为数字 php 怎么将字符转成数字

java中&#xff0c;String字符串转化为数字我现在想把一个String字符串转化为数字&#xff0c; String s"00000123" 我直接使java中String字符串转化为数字&#xff1a; 转换为浮点型&#xff1a; 使用Double或者Float的parseDouble或者parseFloat方法进行转换 Strin…

用U盘作为启动盘做系统步骤

步骤一&#xff1a;BIOS设置U盘启动 制作好Win10 U盘系统安装盘之后&#xff0c;我们需要在电脑的BIOS设置中把第一启动设备设置为U盘&#xff0c;设置后就可以从我们制作的Win10 U盘系统安装盘启动&#xff0c;从而显示系统安装界面开始安装系统。BIOS设置U盘启动的方法如下&a…

使用tkinter模块在Python中进行GUI编程

GUI (Graphical User Interface): GUI(图形用户界面)&#xff1a; GUI is a simple application which helps the user to interact with the computer or any other electronic device through a graphical icon. This used to perform different tasks on a desktop or lapt…

Composer学习之————Ubuntu14.04下安装Composer

下载Composer&#xff1a; curl -sS https://getcomposer.org/installer | php 安装Composer&#xff1a; /usr/bin/php composer.phar --version 设置全局命令&#xff1a; sudo mv composer.phar /usr/local/bin/composer 查看是否安装与设置成功&#xff1a; composer -vers…

java如何解决高并发症,JAVA线上故障紧急处理详细过程!

链接&#xff1a;https://fredal.xin/java-error-check?hmsrtoutiao.io&utm_mediumtoutiao.io&utm_sourcetoutiao.io线上故障主要会包括 CPU、磁盘、内存以及网络问题&#xff0c;而大多数故障可能会包含不止一个层面的问题&#xff0c;所以进行排查时候尽量四个方面依…

php 查看扩展 代码,[扩展推荐] 使用 PHP Insights 在终端查看 PHP 项目代码质量

PHP Insights 是一个由 Nuno Maduro 发布的、可在控制台进行 PHP 即时质量检查的拓展包。在项目的 readme 文件中&#xff0c;可以发现 PHP Insights 的主要功能包含&#xff1a;代码质量 与 代码风格 分析一个针对于代码 结构 和 复杂度 的漂亮的预览界面在 Laravel、Symfon…

航空机票预订c#代码_航空公司座位预订问题的C ++程序

航空机票预订c#代码Problem statement: Write a program to assign passengers seats in an airplane. Assume a small airplane with seat numbering as follows: 问题陈述&#xff1a;编写一个程序来分配飞机上的乘客座位。 假设小型飞机的座位编号如下&#xff1a; 1 A B C…

linux命令之which

which这个命令可以说并不常用&#xff0c;它的作用是查看可执行文件的位置&#xff0c;并返回第一个搜索结果。可执行文件也就是指的某个系统命令&#xff0c;但是这个命令的位置必须是在PATH路径里存在的。截图中 &#xff0c;pwd的位置在/bin/pwd,当然&#xff0c;这个路径是…

线性代数向量乘法_向量的标量乘法| 使用Python的线性代数

线性代数向量乘法Prerequisite: Linear Algebra | Defining a Vector 先决条件&#xff1a; 线性代数| 定义向量 Linear algebra is the branch of mathematics concerning linear equations by using vector spaces and through matrices. In other words, a vector is a mat…

html的学习思维导图

转载于:https://www.cnblogs.com/lingdublog/p/6438088.html

cubic-bezier_带CSS中的示例的cube-bezier()函数

cubic-bezierIntroduction: 介绍&#xff1a; How many times have we come across the word function? Well, it would not be wrong to say a lot. The fact that functions are used in web development while developing a website or web page is very important. There…

上手Caffe(一)

author&#xff1a;oneBite 本文记录编译使用caffe for windows 使用环境 VS2013 ultimate,win7 sp1,caffe-windows源码&#xff08;从github上下载caffe的windows分支&#xff0c;下载解压之后&#xff0c;不要改变原有的目录结构,因为solution rebuild时会使用文件的相对路径…

关于设置不同linux主机之间ssh免密登录简易方法

2019独角兽企业重金招聘Python工程师标准>>> 在linux日常中&#xff0c;经常会有ssh链接其他主机服务器的action,也学习过大家日常用配置ssh免密登录的方法。 小编今天在这里给大家介绍一种比较简单的配置linux主机ssh免密登录的方法。 两台主机的IP地址&#xff1a…

java自定义线程池池,线程池使用及自定义线程池

一 案例引申编写代码同时只允许五个线程并发访问(以下文的函数为例子)private static void method() {System.out.println("ThreadName" Thread.currentThread().getName() "进来了");Thread.sleep(2000);System.out.println("ThreadName" Th…