3

Linux 磁盘空间不够用,这几个命令帮你提升磁盘空间

 1 year ago
source link: https://foofish.net/linux-disk-capacity.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Linux 磁盘空间不够用,这几个命令帮你提升磁盘空间

By 刘志军 , 2023-08-03, 分类: 思考

linux

首先使用 df 命令查看磁盘剩余空间有多少

df -h
image-20230803083805153

比如我这个挂载在根目录的分区已经占用了78%的空间,进入根目录后,使用 du 命令找出大文件

cd /
# 查看大于1G的文件并排序
du -h --max-depth=1 |grep 'G' |sort

通过迭代执行以上操作,找到占用空间最大的文件,比如使用命令找出来有两个文件占用大量空间,一个是 nginx的 access.log 日志文件,另一个是mysql 的 slow.log 日志文件, 占用了将近100个G。

我们直接使用下面的命令将该文件内容置空即可。

> access.log
> slow.log

最后再来看磁盘空间

image-20230803113818325

一下多出了几十个G

关注公众号「Python之禅」,回复「1024」免费获取Python资源

python之禅

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK