1NCDU(1)                           ncdu manual                          NCDU(1)
2
3
4

NAME

6       ncdu - NCurses Disk Usage
7

SYNOPSIS

9       ncdu [options] dir
10

DESCRIPTION

12       ncdu (NCurses Disk Usage) is a curses-based version of the well-known
13       'du', and provides a fast way to see what directories are using your
14       disk space.
15

OPTIONS

17   Mode Selection
18       -h, --help
19           Print a short help message and quit.
20
21       -v, -V, --version
22           Print ncdu version and quit.
23
24       -f FILE
25           Load the given file, which has earlier been created with the "-o"
26           option. If FILE is equivalent to "-", the file is read from
27           standard input.
28
29           For the sake of preventing a screw-up, the current version of ncdu
30           will assume that the directory information in the imported file
31           does not represent the filesystem on which the file is being
32           imported. That is, the refresh, file deletion and shell spawning
33           options in the browser will be disabled.
34
35       dir Scan the given directory.
36
37       -o FILE
38           Export all necessary information to FILE instead of opening the
39           browser interface. If FILE is "-", the data is written to standard
40           output.  See the examples section below for some handy use cases.
41
42           Be warned that the exported data may grow quite large when
43           exporting a directory with many files. 10.000 files will get you an
44           export in the order of 600 to 700 KiB uncompressed, or a little
45           over 100 KiB when compressed with gzip. This scales linearly, so be
46           prepared to handle a few tens of megabytes when dealing with
47           millions of files.
48
49       -e, --extended, --no-extended
50           Enable/disable extended information mode. This will, in addition to
51           the usual file information, also read the ownership, permissions
52           and last modification time for each file. This will result in
53           higher memory usage (by roughly ~30%) and in a larger output file
54           when exporting.
55
56           When using the file export/import function, this flag will need to
57           be added both when exporting (to make sure the information is added
58           to the export), and when importing (to read this extra information
59           in memory). This flag has no effect when importing a file that has
60           been exported without the extended information.
61
62           This enables viewing and sorting by the latest child mtime, or
63           modified time, using 'm' and 'M', respectively.
64
65       --ignore-config
66           Do not attempt to load any configuration files.
67
68   Scan Options
69       These options affect the scanning progress, and have no effect when
70       importing directory information from a file.
71
72       -x, --one-file-system
73           Do not cross filesystem boundaries, i.e. only count files and
74           directories on the same filesystem as the directory being scanned.
75
76       --cross-file-system
77           Do cross filesystem boundaries. This is the default, but can be
78           specified to overrule a previously given "-x".
79
80       --exclude PATTERN
81           Exclude files that match PATTERN. The files will still be displayed
82           by default, but are not counted towards the disk usage statistics.
83           This argument can be added multiple times to add more patterns.
84
85       -X FILE, --exclude-from FILE
86           Exclude files that match any pattern in FILE. Patterns should be
87           separated by a newline.
88
89       --include-caches, --exclude-caches
90           Include (default) or exclude directories containing CACHEDIR.TAG.
91           The directories will still be displayed, but their contents will
92           not be scanned or counted towards the disk usage statistics.
93           <http://www.brynosaurus.com/cachedir/>
94
95       -L, --follow-symlinks, --no-follow-symlinks
96           Follow (or not) symlinks and count the size of the file they point
97           to. As of ncdu 1.14, this option will not follow symlinks to
98           directories and will count each symlinked file as a unique file
99           (i.e. unlike how hard links are handled).  This is subject to
100           change in later versions.
101
102       --exclude-firmlinks, --follow-firmlinks
103           (MacOS only) Exclude or follow firmlinks.
104
105       --include-kernfs, --exclude-kernfs
106           (Linux only) Include (default) or exclude Linux pseudo filesystems,
107           e.g. /proc (procfs), /sys (sysfs).
108
109           The complete list of currently known pseudo filesystems is: binfmt,
110           bpf, cgroup, cgroup2, debug, devpts, proc, pstore, security,
111           selinux, sys, trace.
112
113   Interface options
114       -0  Don't give any feedback while scanning a directory or importing a
115           file, other than when a fatal error occurs. Ncurses will not be
116           initialized until the scan is complete. When exporting the data
117           with "-o", ncurses will not be initialized at all. This option is
118           the default when exporting to standard output.
119
120       -1  Similar to "-0", but does give feedback on the scanning progress
121           with a single line of output. This option is the default when
122           exporting to a file.
123
124           In some cases, the ncurses browser interface which you'll see after
125           the scan/import is complete may look garbled when using this
126           option. If you're not exporting to a file, "-2" is probably a
127           better choice.
128
129       -2  Provide a full-screen ncurses interface while scanning a directory
130           or importing a file. This is the only interface that provides
131           feedback on any non-fatal errors while scanning.
132
133       -q, --slow-ui-updates, --fast-ui-updates
134           Change the UI update interval while scanning or importing. Ncdu
135           will update the screen 10 times a second by default
136           ("--fast-ui-updates"), this can be decreased to once every 2
137           seconds with "-q" or "--slow-ui-updates". This feature can be used
138           to save bandwidth over remote connections. This option has no
139           effect when "-0" is used.
140
141       --enable-shell, --disable-shell
142           Enable or disable shell spawning from the browser. This feature is
143           enabled by default when scanning a live directory and disabled when
144           importing from file.
145
146       --enable-delete, --disable-delete
147           Enable or disable the built-in file deletion feature. This feature
148           is enabled by default when scanning a live directory and disabled
149           when importing from file. Explicitly disabling the deletion feature
150           can work as a safeguard to prevent accidental data loss.
151
152       --enable-refresh, --disable-refresh
153           Enable or disable directory refreshing from the browser. This
154           feature is enabled by default when scanning a live directory and
155           disabled when importing from file.
156
157       -r  Read-only mode. When given once, this is an alias for
158           "--disable-delete", when given twice it will also add
159           "--disable-shell", thus ensuring that there is no way to modify the
160           file system from within ncdu.
161
162       --si, --no-si
163           List sizes using base 10 prefixes, that is, powers of 1000 (KB, MB,
164           etc), as defined in the International System of Units (SI), instead
165           of the usual base 2 prefixes, that is, powers of 1024 (KiB, MiB,
166           etc).
167
168       --disk-usage, --apparent-size
169           Select whether to display disk usage (default) or apparent sizes.
170           Can also be toggled in the browser with the 'a' key.
171
172       --show-hidden, --hide-hidden
173           Show (default) or hide "hidden" and excluded files. Can also be
174           toggled in the browser with the 'e' key.
175
176       --show-itemcount, --hide-itemcount
177           Show or hide (default) the item counts column. Can also be toggled
178           in the browser with the 'c' key.
179
180       --show-mtime, --hide-mtime
181           Show or hide (default) the last modification time column. Can also
182           be toggled in the browser with the 'm' key. This option is ignored
183           when not in extended mode (see "-e").
184
185       --show-graph, --hide-graph
186           Show (default) or hide the relative size bar column. Can also be
187           toggled in the browser with the 'g' key.
188
189       --show-percent, --hide-percent
190           Show (default) or hide the relative size percent column. Can also
191           be toggled in the browser with the 'g' key.
192
193       --sort COLUMN
194           Change the default column to sort on. Accepted values are disk-
195           usage (the default), name, apparent-size, itemcount or mtime. The
196           latter only makes sense in extended mode, see "-e".
197
198           The column can be suffixed with -asc or -desc to set the order to
199           ascending or descending, respectively. e.g. "--sort=name-desc" will
200           sort by name in descending order.
201
202       --enable-natsort, --disable-natsort
203           Enable (default) or disable natural sort when sorting by file name.
204
205       --group-directories-first, --no-group-directories-first
206           Sort (or not) directories before files.
207
208       --confirm-quit, --no-confirm-quit
209           Require a confirmation before quitting ncdu. Very helpful when you
210           accidentally press 'q' during or after a very long scan.
211
212       --confirm-delete, --no-confirm-delete
213           Require a confirmation before deleting a file or directory. Enabled
214           by default, but can be disabled if you're absolutely sure you won't
215           accidentally press 'd'.
216
217       --color SCHEME
218           Select a color scheme. The following schemes are recognized: off to
219           disable colors, dark for a color scheme intended for dark
220           backgrounds and dark-bg for a variation of the dark color scheme
221           that also works in terminals with a light background.
222
223           The default is dark-bg unless the "NO_COLOR" environment variable
224           is set.
225

CONFIGURATION

227       Ncdu can be configured by placing command-line options in
228       "/etc/ncdu.conf" or "$HOME/.config/ncdu/config". If both files exist,
229       the system configuration will be loaded before the user configuration,
230       allowing users to override options set in the system configuration.
231       Options given on the command line will override options set in the
232       configuration files. The files will not be read at all when
233       "--ignore-config" is given on the command line.
234
235       The configuration file format is simply one command line option per
236       line. Lines starting with "#" are ignored. Example configuration file:
237
238         # Always enable extended mode
239         -e
240
241         # Disable file deletion
242         --disable-delete
243
244         # Exclude .git directories
245         --exclude .git
246

KEYS

248       ?   Show help + keys + about screen
249
250       up, down, j, k
251           Cycle through the items
252
253       right, enter, l
254           Open selected directory
255
256       left, <, h
257           Go to parent directory
258
259       n   Order by filename (press again for descending order)
260
261       s   Order by filesize (press again for descending order)
262
263       C   Order by number of items (press again for descending order)
264
265       a   Toggle between showing disk usage and showing apparent size.
266
267       M   Order by latest child mtime, or modified time. (press again for
268           descending order) Requires the -e flag.
269
270       d   Delete the selected file or directory. An error message will be
271           shown when the contents of the directory do not match or do not
272           exist anymore on the filesystem.
273
274       t   Toggle dirs before files when sorting.
275
276       g   Toggle between showing percentage, graph, both, or none. Percentage
277           is relative to the size of the current directory, graph is relative
278           to the largest item in the current directory.
279
280       c   Toggle display of child item counts.
281
282       m   Toggle display of latest child mtime, or modified time. Requires
283           the -e flag.
284
285       e   Show/hide 'hidden' or 'excluded' files and directories. Please note
286           that even though you can't see the hidden files and directories,
287           they are still there and they are still included in the directory
288           sizes. If you suspect that the totals shown at the bottom of the
289           screen are not correct, make sure you haven't enabled this option.
290
291       i   Show information about the current selected item.
292
293       r   Refresh/recalculate the current directory.
294
295       b   Spawn shell in current directory.
296
297           Ncdu will determine your preferred shell from the "NCDU_SHELL" or
298           "SHELL" variable (in that order), or will call "/bin/sh" if neither
299           are set.  This allows you to also configure another command to be
300           run when he 'b' key is pressed. For example, to spawn the vifm(1)
301           file manager instead of a shell, run ncdu as follows:
302
303             export NCDU_SHELL=vifm
304             ncdu
305
306           Ncdu will set the "NCDU_LEVEL" environment variable or increment it
307           before spawning the shell. This variable allows you to detect when
308           your shell is running from within ncdu, which can be useful to
309           avoid nesting multiple instances of ncdu. Ncdu itself does not
310           (currently) warn when attempting to run nested instances.
311
312       q   Quit
313

FILE FLAGS

315       Entries in the browser interface may be prefixed by a one-character
316       flag. These flags have the following meaning:
317
318       !   An error occurred while reading this directory.
319
320       .   An error occurred while reading a subdirectory, so the indicated
321           size may not be correct.
322
323       <   File or directory is excluded from the statistics by using exclude
324           patterns.
325
326       >   Directory is on another filesystem.
327
328       ^   Directory is excluded from the statistics due to being a Linux
329           pseudo filesystem.
330
331       @   This is neither a file nor a folder (symlink, socket, ...).
332
333       H   Same file was already counted (hard link).
334
335       e   Empty directory.
336

EXAMPLES

338       To scan and browse the directory you're currently in, all you need is a
339       simple:
340
341         ncdu
342
343       If you want to scan a full filesystem, your root filesystem, for
344       example, then you'll want to use "-x":
345
346         ncdu -x /
347
348       Since scanning a large directory may take a while, you can scan a
349       directory and export the results for later viewing:
350
351         ncdu -1xo- / | gzip >export.gz
352         # ...some time later:
353         zcat export.gz | ncdu -f-
354
355       To export from a cron job, make sure to replace "-1" with "-0" to
356       suppress any unnecessary output.
357
358       You can also export a directory and browse it once scanning is done:
359
360         ncdu -o- | tee export.file | ./ncdu -f-
361
362       The same is possible with gzip compression, but is a bit kludgey:
363
364         ncdu -o- | gzip | tee export.gz | gunzip | ./ncdu -f-
365
366       To scan a system remotely, but browse through the files locally:
367
368         ssh -C user@system ncdu -o- / | ./ncdu -f-
369
370       The "-C" option to ssh enables compression, which will be very useful
371       over slow links. Remote scanning and local viewing has two major
372       advantages when compared to running ncdu directly on the remote system:
373       You can browse through the scanned directory on the local system
374       without any network latency, and ncdu does not keep the entire
375       directory structure in memory when exporting, so you won't consume much
376       memory on the remote system.
377
379       Every disk usage analysis utility has its own way of (not) counting
380       hard links.  There does not seem to be any universally agreed method of
381       handling hard links, and it is even inconsistent among different
382       versions of ncdu. This section explains what each version of ncdu does.
383
384       ncdu 1.5 and below does not support any hard link detection at all:
385       each link is considered a separate inode and its size is counted for
386       every link. This means that the displayed directory sizes are incorrect
387       when analyzing directories which contain hard links.
388
389       ncdu 1.6 has basic hard link detection: When a link to a previously
390       encountered inode is detected, the link is considered to have a file
391       size of zero bytes.  Its size is not counted again, and the link is
392       indicated in the browser interface with a 'H' mark. The displayed
393       directory sizes are only correct when all links to an inode reside
394       within that directory. When this is not the case, the sizes may or may
395       not be correct, depending on which links were considered as "duplicate"
396       and which as "original". The indicated size of the topmost directory
397       (that is, the one specified on the command line upon starting ncdu) is
398       always correct.
399
400       ncdu 1.7 and later has improved hard link detection. Each file that has
401       more than two links has the "H" mark visible in the browser interface.
402       Each hard link is counted exactly once for every directory it appears
403       in. The indicated size of each directory is therefore, correctly, the
404       sum of the sizes of all unique inodes that can be found in that
405       directory. Note, however, that this may not always be same as the space
406       that will be reclaimed after deleting the directory, as some inodes may
407       still be accessible from hard links outside it.
408

BUGS

410       Directory hard links are not supported. They will not be detected as
411       being hard links, and will thus be scanned and counted multiple times.
412
413       Some minor glitches may appear when displaying filenames that contain
414       multibyte or multicolumn characters.
415
416       All sizes are internally represented as a signed 64bit integer. If you
417       have a directory larger than 8 EiB minus one byte, ncdu will clip its
418       size to 8 EiB minus one byte. When deleting items in a directory with a
419       clipped size, the resulting sizes will be incorrect.
420
421       Item counts are stored in a signed 32-bit integer without overflow
422       detection.  If you have a directory with more than 2 billion files,
423       quite literally anything can happen.
424
425       On macOS 10.15 and later, running ncdu on the root directory without
426       `--exclude-firmlinks` may cause directories to be scanned and counted
427       multiple times. Firmlink cycles are currently (1.16) not detected, so
428       it may also cause ncdu to get stuck in an infinite loop and eventually
429       run out of memory.
430
431       Please report any other bugs you may find at the bug tracker, which can
432       be found on the web site at https://dev.yorhel.nl/ncdu
433

AUTHOR

435       Written by Yoran Heling <projects@yorhel.nl>.
436

SEE ALSO

438       du(1)
439
440
441
442ncdu-1.18.1                       2023-03-05                           NCDU(1)
Impressum