will it not affect running applications like if it removes any necessary package on which any application depends?.
–
user3215Oct 11 '10 at 13:54

1

No. Autoremove looks for orphaned packages, that is to say packages that you didn't explicitly install yourself (ones marked auto) and that have no dependencies. If you use aptitude instead of apt-get, it can clean up as you go but it's quite common for older installations to collect a raft of installed kernels as security updates come out.
–
Oli♦Oct 11 '10 at 14:03

1

Typo in my last comment. I meant to say that orphaned packages are ones that aren't depended on, not ones that "have no dependencies". They may well have dependencies and if they were only there for that orphaned package, they'll be removed too. Some times (with really deep dependency trees) it can take a couple of autoremoves to clean up.
–
Oli♦Oct 11 '10 at 14:28

4

While the above command is certainly useful, it will not, as stated, remove old kernels. That has to be done either manually or with additional tools like Ubuntu Tweak.
–
codelingAug 17 '13 at 8:33

1

@nyarlathotep It will remove kernel header files, which at first glance may make one think it's removing the old kernels - the old kernels remain, however (try dpkg --get-selections | grep linux-image).
–
drevickoDec 1 '13 at 23:55

Try using BleachBit (located at sourceforge). It is a great program.
the basic idea is that it quickly frees up disk space and removes a lot of the junk that is hidden in the system. There are about 70 applications that it can recognize and wipe clean. There is also the ability to use it to "wipe" the free disk space. I think of it as CCleaner from windows only for linux.

First, there is a tool for listing all big folders and files. Just type 'Baobab' into the launcher. By removing folders and files you don't need you get more space.

Then, there is a program for removing double files. The program is called fslint.
Install it by entering

sudo apt-get install fslint

in a Terminal.

or graphically

You can also clear the package cache with

sudo apt-get autoclean
sudo apt-get clean
sudo apt-get autoremove

The fourth step is to remove old Kernel entries.
You can do this by installing and opening Synaptic. In Synaptic, search for the old Kernel entries (every Kernel entry that is displayed in GRUB except the newest) and remove it.

One good step is to remove the application cache. Do this by installing and running bleachbit:

sudo apt-get install bleachbit

or graphically

Important: Deleted cache cannot be restored!

The last step is to defragment the file system.
Do the following for this:

The '/tmp' directory should never be cleaned up manually unless absolutely necessary (ie: a closed application didn't clean-up after itself).

You can search where space might be filling up using the 'du' command; usually places of interest are inside '/var'. To name two usual suspects '/var/log' and '/var/cache'. Though I've had some users who install a backup utility and never realise that it creates GBs of incremental backups in '/var/backup' that build up over a week or month to fill the entire disk space.

When I need make more free space on servers I use this command. It find all files bigger then 50 MB and "du -h" make better list of files and "sort -n" after pipe make list numericcaly sorted by file size.