Last active
May 13, 2019 03:11
-
-
Save zhuchaowe/6ea4295876ba6df2061d2c5f9f1a0f8c to your computer and use it in GitHub Desktop.
搜集常用的Linux命令
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. Linux系统磁盘使用空间不足时,如何查找大文件并进行清理的方法。 | |
| ``` | |
| 查找大于100M的大文件: | |
| find / -size +100M -exec ls -lh {} \; | |
| ``` | |
| 2.Linux查看磁盘空间大小 | |
| 查看磁盘空间大小:`df -h` | |
| 查看文件大小:`du -h *` | |
| 查看目录大小的命令是du(当然也可以查看文件大小),例如:du ems_data,就是查看ems_data目录下各子目录的大小;du,就是查看当前目录下各子目录的大小;du *,就是查看当前目录下各子目录和文件的大小。 | |
| 为了提高查看效果,我们需要对结果进行排序,因为du的命令结果很乱,例如: | |
| 从大到小排列:du ems_data | sort -nr | |
| 按目录名排列:du ems_data | sort +1 -2 | |
| 选出排在前面的10个:du ems_data | sort -rn | head | |
| 选出排在后面的10个:du ems_data | sort -rn | tail | |
| 当前目录的大小:du -sh . | |
| 顺便说一下,df命令可以查看硬盘各分区使用情况,命令为df或者df -kv,kv表示以Kbyte为单位显示大小 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment