Linux使用ncdu查看磁盤(pán)使用的操作詳解
簡(jiǎn)介
ncdu (NCurses Disk Usage)
是一個(gè)用于 Linux
和類(lèi) unix
系統(tǒng)的磁盤(pán)實(shí)用程序,它提供了一種比 du
等傳統(tǒng)命令更具交互性和用戶友好性的方式來(lái)查看和分析磁盤(pán)空間使用情況。它提供了一個(gè)導(dǎo)航界面,允許您輕松識(shí)別哪些目錄和文件占用了最多的磁盤(pán)空間。
安裝
Ubuntu/Debian
sudo apt update sudo apt install ncdu
RedHat/CentOS/Fedora
sudo yum install ncdu # or sudo dnf install ncdu
示例用法
掃描當(dāng)前目錄
它將列出當(dāng)前目錄中的所有目錄和文件,并按磁盤(pán)使用量排序。最大的文件和目錄將首先列出。
ncdu
支持的鍵
↑,↓ or k,j to Move →,l to enter ←,h to return g toggle graph c toggle counts a toggle average size in directory m toggle modified time u toggle human-readable format n,s,C,A,M sort by name,size,count,asize,mtime d delete file/directory v select file/directory V enter visual select mode D delete selected files/directories y copy current path to clipboard Y display current path ^L refresh screen (fix screen corruption) r recalculate file sizes ? to toggle help on and off q/ESC/^c to quit
掃描特定目錄
ncdu /path/to/directory
示例
ncdu ~/Documents
ncdu 中的常用導(dǎo)航
描完成后,將看到一個(gè)屏幕,其中顯示指定目錄中的目錄和文件及其磁盤(pán)使用情況。
箭頭鍵(上/下):在目錄和文件列表中上
回車(chē)/右箭頭:進(jìn)入選定的目錄
左箭頭:返回父目錄
q:退出
ncdu
程序d:刪除選擇的文件或目錄
?:顯示幫助信息
n:按名稱(chēng)(而不是磁盤(pán)使用情況)對(duì)輸出進(jìn)行排序
s:按大小對(duì)輸出進(jìn)行排序(默認(rèn)排序方法)
排除特定目錄
如果不想在掃描中包含某些目錄,可以使用 -x
選項(xiàng)排除單獨(dú)掛載的文件系統(tǒng)(對(duì)于排除外部驅(qū)動(dòng)器或網(wǎng)絡(luò)掛載很有用)
ncdu -x /path/to/directory
顯示隱藏的文件
默認(rèn)情況下,ncdu
可能不會(huì)顯示隱藏文件(以點(diǎn)開(kāi)頭的文件,如 .bashrc
)
ncdu -a /path/to/directory
掃描多個(gè)目錄
ncdu /path/to/dir1 /path/to/dir2
排除特定文件或目錄
-x
或 --exclude
ncdu --exclude /path/to/exclude /path/to/directory
保存輸出
可以使用 -o
(輸出)標(biāo)志將掃描結(jié)果保存到文件中。允許生成報(bào)告以供以后分析
ncdu -o output_file /path/to/directory
加載保存的輸出文件
ncdu -f output_file
掃描家目錄
ncdu ~
以上就是Linux使用ncdu查看磁盤(pán)使用的操作詳解的詳細(xì)內(nèi)容,更多關(guān)于Linux ncdu查看磁盤(pán)使用的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
在CentOS VPS上通過(guò)SSH安裝 MySQL的方法圖解
這篇文章主要介紹了在CentOS VPS上通過(guò)SSH安裝 MySQL,需要的朋友可以參考下2018-12-12ubuntu22.04?server安裝及使用詳細(xì)圖文教程
這篇文章主要給大家介紹了關(guān)于ubuntu22.04?server安裝及使用的相關(guān)資料,Ubuntu Server是Ubuntu家族的一員,專(zhuān)為網(wǎng)絡(luò)和服務(wù)量身定制,文中通過(guò)圖文介紹的非常詳細(xì),需要的朋友可以參考下2023-10-10Linux防火墻配置及iptables與firewalld的使用解讀
防火墻是一種網(wǎng)絡(luò)安全設(shè)備,通過(guò)規(guī)則控制進(jìn)出網(wǎng)絡(luò)的訪問(wèn)行為,它分為硬件防火墻和軟件防火墻兩大類(lèi),iptables是Linux系統(tǒng)中用于配置防火墻的工具,具有4個(gè)表和5個(gè)鏈,firewall命令用于配置和管理防火墻,有drop、block、public、external、dmz等不同的區(qū)域配置2025-01-01