8

My hard drive became full. I am looking for ways to locate the things that use most of my disk space. I played with cron once so it may have consumed a great deal of space, but really I have no clue.

I have backed up my things to CDs, but the system is still getting too slow. Perhaps I should reinstall everything, but whilst fixing the problem it doesn't address the cause.

Testing KamilMaciorowski's answer for ncdu

I run ncdu as root and get the following where I missed out the backup file in my system by other methods

--- /home/masi ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   45.5GiB [##########]  backup_home_1.9.2016.tar.gz
   34.9GiB [#######   ] /Documents                                                                                                                                                                                 
    1.4GiB [          ] /Videos
    1.4GiB [          ] /.cache
    1.2GiB [          ] /Downloads
    1.0GiB [          ] /.config
  607.8MiB [          ] /Pictures
  487.0MiB [          ] /.matlab
  447.2MiB [          ] /Images
  406.1MiB [          ] /Desktop
   97.1MiB [          ] /.kingsoft
   58.4MiB [          ] /.local
   20.6MiB [          ] /.Mathematica
   13.3MiB [          ] /.mozilla
   ...
1
  • 1. You should really specify the OS for which you are looking tools and suggestions. (though seeing your username might be enough of an answer :-)) 2. I have the sneaky suspicion that this question will be closed as "Not programming related"... Feb 14, 2009 at 6:01

7 Answers 7

3

Linux tool ncdu is very convenient in my opinion. It's like interactive du.

Some features

  • Text interface (ncurses); works via SSH, no Xserver needed.
  • Still you can move within directory tree to find large dirs/files quickly.
  • You can delete dir/file from within the program.

Screenshot

Well, kind of. There's no point in pasting picture, text will be enough:

ncdu 1.10 ~ Use the arrow keys to navigate, press ? for help                    
--- / --------------------------------------------------------------------------
    6,7GiB [##########] /usr
    3,4GiB [#####     ] /var
  553,1MiB [          ] /lib
  529,1MiB [          ] /opt
   35,1MiB [          ] /etc
   32,5MiB [          ] /home_old                                               
   16,4MiB [          ] /sbin
    9,9MiB [          ] /bin
    8,2MiB┌───ncdu help─────────────────1:Keys───2:Format───3:About──┐
    3,8MiB│                                                          │
    1,3MiB│       up, k  Move cursor up                              │
  500,0KiB│     down, j  Move cursor down                            │
  124,0KiB│ right/enter  Open selected directory                     │
   12,0KiB│  left, <, h  Open parent directory                       │
    8,0KiB│           n  Sort by name (ascending/descending)         │
@   4,0KiB│           s  Sort by size (ascending/descending)         │
@   4,0KiB│           C  Sort by items (ascending/descending)        │
@   4,0KiB│           d  Delete selected file or directory           │
    0,0  B│           t  Toggle dirs before files when sorting       │
>   0,0  B│           g  Show percentage and/or graph                │
e   0,0  B│                        -- more --                        │
>   0,0  B│                                     Press q to continue  │
>   0,0  B└──────────────────────────────────────────────────────────┘
>   0,0  B [          ] /home
>   0,0  B [          ] /dev
e   0,0  B [          ] /cpusets
e   0,0  B [          ] /cdrom
>   0,0  B [          ] /boot



 Total disk usage:  11,3GiB  Apparent size:  11,1GiB  Items: 289029             

Usage:

ncdu -x /foo/bar/mountpoint

Use sudo (and caution!) when necessary. The -x option is important, it makes ncdu stay within single filesystem (du has the same option). In the example (above) my /home is on a different partition than / where ncdu started, therefore it does not count – thanks to -x switch exactly.

1
  • This tool is very powerful! Thank you very much for pointing it out! It finds easily culprits in my system; those which I did not find by my systematic way because it is so easy to miss things in big systems. Sep 19, 2016 at 11:04
7

KDirStat is another option which will help you identify large files and directories.

alt text

I've used the Windows clone WinDirStat a lot and it is an awesome tool.

7

"I played with cron once so it may have consumed my mass memory, but really I have no clue." No clue, you say? never would have guessed. :)

su -
cd /
du -s ./* | sort -n
  • du shows disk usage, in blocks (1 block = 0.5 kilobytes, in all cases that matter to you.)

  • -s means, "summary", so it gives only a total for each argument "./*" being the argument.

  • piping it into sort -n means sort numerically. The larger numbers at the bottom.

  • So, you'll get a list of directories with the ones using the most space at the bottom.

If that's not enough help, say you get:

60380   ./root
142468  ./etc
537716  ./var
627264  ./lib
5757600 ./usr
28859472        ./home
  • and you see that ./home is the biggest piggy, ok, cd into /home, and do the same du -s | sort -n. Then you see who in /home is taking up space. (on a single user system, well, it's probably you.)

  • Then cd into there, and do du -s | sort -n again.

Keep doing this until you find the culprit. When you find the culprit, you may say, oh yeah... that's my collection of hi-res renderings of Romulan Birds of Prey for my star trek RPG game that I'm building, so yeah, of course that takes up a lot of space, or you may say, of course that takes up a lot of space, so let's rm -fr that bad boy.

Magic words to remember:

du -s | sort -n
2

Check out the Disk Usage Analyzer, you can find it in Programs -> Accessories, it will analyze the disk usage and show it as a diagram to you.

Also, remove unnecessary programs and clear out the old package cache by running sudo apt-get clean .

2

To expand on Bobby's last point, run:

sudo apt-get autoremove
sudo apt-get autoclean

…to clear out all extra packages and unneeded install files. Also, it would be a really good idea to go through your applications and remove the ones you don’t use any more.

1
  • I added an example about your command in the body. I really like your autoclean. Actually, I have never used it before intentionally. It really saved many MBs from my SSD. Sep 18, 2016 at 9:03
1

Per the "Linux Server Hacks" by O'Reilly

alias ducks='du -cks * | sort -rn | head -11'

Then go to any directory and run the alias

1
  • I would use du -cksh to get the sizes in MB/GB!
    – SPRBRN
    Jun 5, 2013 at 12:39
0

Software built-in: Disk Usage Analyzer. Fig. 1 Polar coordinate view of masi's /, Fig. 2 Rectangular view of masi's / where you move your mouse to visualize contents

enter image description here enter image description here

Delete things which you do not need then

  1. manually after inspection carefully
  2. clean packages in apt-get

    # http://superuser.com/a/113904/2005
    su 
    apt-get autoclean
    
    • Example output in my Asus Zenbook UX303UA where I use the Linux kernel backports (currently 4.6)

      root@masi:/home/masi# apt-get autoclean
      Reading package lists... Done
      Building dependency tree       
      Reading state information... Done
      Del chromium 53.0.2785.89-1~deb8u1 [42.0 MB]
      Del chromium 52.0.2743.116-1~deb8u1 [41.3 MB]
      Del libtomcat7-java 7.0.56-3+deb8u3 [3,623 kB]
      Del mysql-common 5.5.50-0+deb8u1 [81.8 kB]
      Del libmysqlclient18 5.5.50-0+deb8u1 [675 kB]
      Del libservlet3.0-java 7.0.56-3+deb8u3 [314 kB]
      Del linux-libc-dev 3.16.7-ckt25-2+deb8u3 [1,025 kB]
      
  3. Remove unused packages if you do not have dependency problems

    apt-get autoremove      
    
  4. ...

There are also tools which try to find duplicate files in your system

  • use merge and diff tools too to find duplicates in directories
  • fdupes, however, can delete wrong files so I am not using it anymore
  • ...

If you have an updated working tree and you want to replace an old one in your other system

  1. Use rsync by knowing your case precisely because it is sharp - can be efficient or work against you if you do not know what you are doing

OS: Debian 8.5
Window manager: Gnome 3.14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .