Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5eca3b9

Browse files
feat: add ncdu command (#673)
* add ncdu command Add detailed documentation for the ncdu command, including installation methods, common options, interactive key bindings, and usage examples.The page follows the same style as other command references. * Revise ncdu documentation 对文件开头的格式做出了修改
1 parent 8d2804a commit 5eca3b9

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

‎command/ncdu.md‎

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
ncdu
2+
===
3+
4+
磁盘使用情况的交互式查看工具,可视为 du 的增强版本
5+
6+
## 补充说明
7+
8+
**ncdu**(**NC**urses **D**isk **U**sage)是 Unix 系统上一款基于 ncurses 的磁盘占用分析工具,可视为传统 `du` 命令的增强版本。
9+
`du` 输出静态文本不同,**ncdu 提供交互式 TUI 界面**,可通过方向键浏览目录树,并支持排序、查看文件信息、直接删除文件等功能。
10+
它非常适合用于快速定位大文件、分析磁盘空间占用以及磁盘清理。1.09+ 版本支持将扫描结果导出为 JSON。
11+
12+
官网
13+
14+
* 官方网站(作者主页):[https://dev.yorhel.nl/ncdu](https://dev.yorhel.nl/ncdu)
15+
* Wikipedia:[https://en.wikipedia.org/wiki/Ncdu](https://en.wikipedia.org/wiki/Ncdu)
16+
17+
### ncdu 安装
18+
19+
在大多数的 Linux 发行版中你同样不会看到 **ncdu** 被默认预装,但作为最常用的磁盘分析工具之一,它几乎在所有主流发行版的官方仓库中都可以直接安装。
20+
21+
不同系统的安装方式如下:
22+
23+
#### **Debian/Ubuntu**
24+
25+
```shell
26+
sudo apt install ncdu
27+
```
28+
29+
#### **CentOS / Rocky / AlmaLinux**
30+
31+
```shell
32+
sudo yum install epel-release
33+
sudo yum install ncdu
34+
```
35+
36+
#### **Fedora**
37+
38+
```shell
39+
sudo dnf install ncdu
40+
```
41+
42+
#### **Arch Linux**
43+
44+
```shell
45+
sudo pacman -S ncdu
46+
```
47+
48+
#### **macOS(Homebrew)**
49+
50+
```shell
51+
brew install ncdu
52+
```
53+
54+
#### **FreeBSD**
55+
56+
```shell
57+
pkg install ncdu
58+
```
59+
60+
### 语法
61+
62+
```shell
63+
ncdu [选项] [目录]
64+
```
65+
66+
### 选项
67+
68+
```shell
69+
-h, --help 显示帮助信息。
70+
-v, --version 显示版本号。
71+
-x 限制扫描在单一文件系统中(不跨挂载点)。
72+
-q 减少屏幕刷新次数(适合远程 SSH)。
73+
-o FILE 将扫描结果导出为 FILE(JSON 格式,需 1.09+)。
74+
-f FILE 从 JSON 文件加载扫描结果(需 1.09+)。
75+
--exclude PATTERN 排除符合模式的文件或目录。
76+
--exclude-from FILE 从文件读取排除模式。
77+
--follow-symlinks 跟随符号链接。
78+
--confirm-deletion 删除文件时要求确认。
79+
```
80+
81+
### 交互说明
82+
83+
↑, ↓, →, ← 代表键盘方向键
84+
85+
| 按键 | 功能 |
86+
| ------------- | ------------------------------- |
87+
| ↑ / k | 上移光标 |
88+
| / j | 下移光标 |
89+
| → / Enter / l | 打开当前目录 |
90+
| ← / h | 返回父目录 |
91+
| n | 按名称排序(再次按切换升/降序) |
92+
| s | 按大小排序(再次按切换升/降序) |
93+
| d | 删除选中项 |
94+
| g | 显示百分比/图表 |
95+
| t | 排序时切换"目录优先" |
96+
| c | 显示或隐藏子项数量 |
97+
| b | 在当前目录打开 shell |
98+
| i | 查看选中文件/目录的详细信息 |
99+
| r | 刷新/重新扫描当前目录 |
100+
| q | 退出 ncdu |
101+
102+
### 实例
103+
104+
#### 扫描当前目录
105+
106+
```shell
107+
ncdu
108+
```
109+
110+
#### 扫描指定目录(示例:/var/log)
111+
112+
```shell
113+
ncdu /var/log
114+
```
115+
116+
#### 导出扫描结果为 JSON(1.09+)
117+
118+
```shell
119+
ncdu -o result.json /
120+
```
121+
122+
#### 从 JSON 文件加载结果
123+
124+
```shell
125+
ncdu -f result.json
126+
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /