Utility ncdu (NCurses Disk Usage) allows you to analyze disk space interactively. It displays data in a pseudo-graphical interface and allows you to quickly navigate through a tree-like directory structure. Available by default on all regular and businesshosting.
For start connect to your hosting account via SSH and run the command:
Once started, ncdu scans the disk space for the directory tree, starting with the current one. You can interrupt scanning by pressing q.
At startup, you can explicitly set what to scan:
The utility can be run with various keys:
–exclude=path/to/directory- exclude the specified directory from scanning.
-o result.txt- run a scan and save the results to the specified file.
-f result.txt- instead of scanning, open the results from the specified file. Note By default, the utility considers the file to be irrelevant to the current file system, so the keys for rescanning, deleting files / directories, and opening the console will be disabled.
-e- extended scanning. Additionally scanned: the time of changing files and directories, access rights, information about the owner. Attention When working with scan results from a file, the key must be used both when saving and opening.
–exclude template- exclude from scanning files and directories that match the template (they will be displayed, but will not be taken into account in statistics). The key can be specified several times.
–exclude-from file- exclude from scanning files and directories that match the templates listed in the specified file (each template on a new line).
–follow-symlinks- when scanning, follow the symlinks and take into account in statistics the sizes of files and directories to which they point.
-r- prohibition of deleting files and directories from the utility (read-only mode).
-rr- prohibition of opening the console in the current directory.
–confirm-quit- require confirmation upon exit.
A complete list of keys can be found in the help by running the command:
Information is displayed in several columns:
e- an empty directory.
@- the item is not a file or directory (eg symlink, socket, etc.).
<- file / directory is excluded from statistics (see. thekeys).
!- error while reading the directory.
.- an error occurred while reading a subdirectory (the size may not be correct).
#shows which of the files / subdirectories in the current directory is taking up more space.
Below is information about the current directory:
-e) additionally displays the rights and the date of change.
Scanning the entire contents of the hosting account, saving the results to a file and archiving it:
ncdu -1xo- ~ | gzip > result.gz
zcat result.gz | ncdu -f-
Scanning the current directory, saving the results to a file and opening for analysis:
ncdu -o- | tee result.txt | ncdu -f-