The ncdu command for Linux is very good for listing the sizes of the files in a directory. Type sudo apt install ncdu
to install this command.
Then run ncdu in a directory to list all files. Press the ‘s’ key to sort the largest files first. This is an easy way to see what files are using the most space. ncdu may also be used over ssh. Type man ncdu
to get more information.
--- /home/ubuntu/Documents ------------------------------------------------------------------------------------------------------------------------------------------------- 22.4MiB [##########] /wpscan 19.6MiB [######## ] system.save 16.6MiB [####### ] /impacket-read-only 9.2MiB [#### ] SYSTEM 4.7MiB [## ] /python 256.0KiB [ ] SECURITY 256.0KiB [ ] SAM 64.0KiB [ ] sam.save 64.0KiB [ ] secretsdump.py 32.0KiB [ ] security.save 12.0KiB [ ] read 12.0KiB [ ] a.out 8.0KiB [ ] virii.S 8.0KiB [ ] recipe-502268-1.py 8.0KiB [ ] /.bundle e 4.0KiB [ ] /.config 4.0KiB [ ] hole.o 4.0KiB [ ] id_rsa 4.0KiB [ ] read.c 4.0KiB [ ] hashes.out 4.0KiB [ ] my.c 4.0KiB [ ] nikto-pinterest-log.log 4.0KiB [ ] id_rsa.pub |
Use the up and down arrow keys to scroll through the files and press i to get information on a file.
--- /home/ubuntu/Documents ------------------------------------------------------------------------------------------------------------------------------------------------- 22.4MiB [##########] /wpscan 19.6MiB [######## ] system.save 16.6MiB [####### ] /impacket-read-only 9.2MiB [#### ] SYSTEM 4.7MiB [## ] /python 256.0KiB [ ] SECURITY 256.0KiB [ ] SAM 64.0KiB [ ] sam.save 64.0KiB [ ] secretsdump.py 32.0KiB [ ] security.save 12.0KiB [ ] read 12.0KiB [ ] a.out 8.0KiB [ ] virii.S 8.0KiB [ ] recipe-502268-1.py 8.0KiB [ ] /.bundle e 4.0KiB [ ] /.config 4.0KiB [ ] hole.o 4.0KiB [ ] id_rsa 4.0KiB [ ] read.c ┌───Item info──────────────────────────────────────────────┐ 4.0KiB [ ] hashes.out │ │ 4.0KiB [ ] my.c │ Name: virii.S │ 4.0KiB [ ] nikto-pinterest-log.log │ Path: /home/ubuntu/Documents │ 4.0KiB [ ] id_rsa.pub │ Type: File │ │ │ │ Disk usage: 8.0KiB (8,192 B) │ │ Apparent size: 7.6KiB (7,754 B) │ │ │ │ Press i to hide this window│ └──────────────────────────────────────────────────────────┘ |
This command-line usage will save a directory listing to a text file.
ubuntu ~/Documents $ ncdu -o documents.lst |
Then load the directory listing into ncdu with this command line.
ubuntu ~/Documents $ ncdu -f documents.lst |
This is a very useful utility for a Linux machine, this allows a very quick look at what files are taking up the most space on the filesystem.
To list files on a remote server that has ncdu installed, do this.
┌──(john㉿DESKTOP-PF01IEE)-[~]<br>└─$ ssh -C jason@192.168.1.2 ncdu -o- /home/jason/Documents | ncdu -f- |
This retrieves a listing of files in the remote folder and then displays it on the local machine.
ncdu 1.17 ~ Use the arrow keys to navigate, press ? for help [imported] --- /home/jason/Documents ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 19.3 MiB [########################################] 20210302_105440.jpg 5.9 MiB [############ ] /Boomsrc 4.4 MiB [######### ] /xVST 3.7 MiB [####### ] 1643434357547.png 3.3 MiB [###### ] 1651802601655.jpg 3.0 MiB [###### ] 1654140841555.jpg 2.4 MiB [#### ] ballgirl.webm 1.7 MiB [### ] xVST_2_5_1_x64-linux-dynamic.tar.gz 1.6 MiB [### ] 20210607_154601.jpg 1.5 MiB [### ] ballreaction.webm 1.1 MiB [## ] scotty-tradie.webm 988.0 KiB [# ] 20220123_120418.jpg 556.0 KiB [# ] /ipaudit-0.95 428.0 KiB [ ] 1658719799030196.webm 408.0 KiB [ ] telstrawpa-01.cap 332.0 KiB [ ] 20220501090520_1.jpg 280.0 KiB [ ] title.xcf 236.0 KiB [ ] message.txt 204.0 KiB [ ] 20220101_084133.jpg 160.0 KiB [ ] 20220501154818_1.jpg 92.0 KiB [ ] title-new-2.webp 88.0 KiB [ ] rabid-science.zip 72.0 KiB [ ] Untitled.xcf 52.0 KiB [ ] ipaudit-0.95.tgz 36.0 KiB [ ] GPL.txt 32.0 KiB [ ] title-trans.webp 32.0 KiB [ ] 1642131874442.png 24.0 KiB [ ] title3.webp 16.0 KiB [ ] title-new.webp 16.0 KiB [ ] title.webp 12.0 KiB [ ] new-title-fancy.webp e 4.0 KiB [ ] /this_is_a_dir_ 4.0 KiB [ ] 08-02-03.zip 4.0 KiB [ ] install.sh 4.0 KiB [ ] makefile 4.0 KiB [ ] readme.txt 4.0 KiB [ ] ai1.c~ 4.0 KiB [ ] ai1.c 4.0 KiB [ ] ai.c 4.0 KiB [ ] testing.c 4.0 KiB [ ] soap.py 4.0 KiB [ ] nc.nasm 4.0 KiB [ ] test.txt 4.0 KiB [ ] nc 0.0 B [ ] nohup.out |