How to clean up unnecessary files

daisy's answer to use a graphical tool to visually find large files and directories is probably the best method. However, do note that "graphical tool" does not mean "requires an X server"! The wonderful ncdu program provides the graphical output in the CLI, and works perfectly on remote servers via SSH:

$ ncdu /

.  43.7GiB [##########] /home
.   5.9GiB [#         ] /usr
    1.1GiB [          ] /lib
.   1.1GiB [          ] /var
  736.9MiB [          ] /opt
. 324.6MiB [          ] /tmp
  218.4MiB [          ] /boot
.  63.8MiB [          ] /etc
   10.0MiB [          ] /sbin
    8.8MiB [          ] /bin
    3.3MiB [          ] /lib32
.   1.0MiB [          ] /run
   64.0KiB [          ] /build
!  16.0KiB [          ] /lost+found
    8.0KiB [          ] /media
    8.0KiB [          ] /mnt
    8.0KiB [          ] /.config
    4.0KiB [          ] /dev
    4.0KiB [          ] /lib64
e   4.0KiB [          ] /srv
e   4.0KiB [          ] /selinux
!   4.0KiB [          ] /root
e   4.0KiB [          ] /cdrom
.   0.0  B [          ] /proc
.   0.0  B [          ] /sys
@   0.0  B [          ]  initrd.img.old
@   0.0  B [          ]  initrd.img
@   0.0  B [          ]  vmlinuz.old

Then, after entering /var/ for instance:

. 395.3MiB [##########] /tmp
. 365.0MiB [######### ] /cache
. 297.8MiB [#######   ] /lib
   16.1MiB [          ] /backups
.   8.0MiB [          ] /log
.  56.0KiB [          ] /spool
   40.0KiB [          ] /games
    8.0KiB [          ] /www
e   4.0KiB [          ] /opt
e   4.0KiB [          ] /mail
e   4.0KiB [          ] /local
e   4.0KiB [          ] /crash
@   0.0  B [          ]  lock
@   0.0  B [          ]  run

Install easily on Debian or Ubuntu:

$ sudo apt-get install ncdu

Install easily on CentOS as root:

# yum install ncdu

The best way of finding out disk consuming, is using graphical software like baobab:

Launch it with sudo baobab /

enter image description here


Debian offers a utility called cruft IIRC that lists files that could possibly be uneeded on your system.