Skip to content

Linux disk visualization tool - ncdu

homepage-banner

Introduction

If you’re a Linux user, you’re probably familiar with the frustration that comes when you run out of disk space. It can be difficult to determine exactly which files and directories are taking up the most space, especially if you’re working on a server without a graphical interface. Fortunately, there’s a powerful and easy-to-use tool that can help: NCdu.

How ncdu Works

Ncdu is a command-line tool that scans your file system and creates a visual representation of the disk usage. It works by traversing the file system and creating a list of directories and files, sorted by size. You can then navigate through this list and explore the disk usage of each directory and file. Ncdu provides an interactive interface that allows you to delete files, move them to another directory, or simply view their contents.

Usage

Quickly search for a directory with large storage usage when the disk space is almost full.

ncdu /var

Output

ncdu 1.15.1 ~ Use the arrow keys to navigate, press ? for help                                                                                                           
--- /var -------------------------------------
  492.0 MiB [##########] /crash
  165.4 MiB [###       ] /lib
   62.6 MiB [#         ] /cache
   46.9 MiB [          ] /opt
   20.1 MiB [          ] /log
  440.0 KiB [          ] /spool
   20.0 KiB [          ] /tmp
   12.0 KiB [          ] /kerberos
   12.0 KiB [          ] /db
    8.0 KiB [          ] /empty
e   4.0 KiB [          ] /yp
e   4.0 KiB [          ] /preserve
e   4.0 KiB [          ] /nis
e   4.0 KiB [          ] /local
e   4.0 KiB [          ] /gopher
e   4.0 KiB [          ] /games
e   4.0 KiB [          ] /ftp
e   4.0 KiB [          ] /adm
    4.0 KiB [          ]  .updated
@   0.0   B [          ]  lock
@   0.0   B [          ]  mail
@   0.0   B [          ]  run

Conclusion

Ncdu is a powerful and useful tool for exploring disk usage on your Linux machine. Its interactive and intuitive interface makes it easy to navigate through your file system and identify what is taking up the most space. If you find yourself running out of disk space or simply want to keep your file system organized, give ncdu a try.

Further reading

  • https://stackoverflow.com/questions/19951883/du-counting-hardlinks-towards-filesize
Leave a message