given a package name, I want to find how much space would be freed up if the package, and its dependencies, were deleted.
As dependencies might be shared between packages, maybe the right way to put it is: How much space does a package take, including all dependencies that are only beeing used by this package
I would prefer CLI solutions, because I would use them in scripts
Simplest and bug free way to get the space used by a program and all its dependencies is to use apt itself. Note dependencies that are not used by another program, but installed with a package, is not considered as they are not removed.
Simply
or
usage
apt-space-used-by PACKAGENAME
This python script looks promising (bigpkg - find packages that require a lot of space on your system)
Simply try following command ( to get disk space freed by purge):
or
where replace
<package>
with yourpackage-name
( example:gimp
)This will not purge package with dependencies but only gives how much disk space will be freed with help of
grep
!Using
dpkg --print-avail
orapt-cache show
:or
This will display installed size of
<package>
.Example:
Sort list of installed packages by size
You can use more for page-wise:
Above list packages according to size acceding, you can use
tail
to list packages consuming top size as follows:Using
dpigs
(from mandpigs
):This Can be installed by:
sudo apt-get install debian-goodies
Example of run command
Finding size of Unused package:-
First run
popularity-contest
and thenpopcon-largest-unused
, This will help you to find size of unused package. Visit man-pages for more information.I tried my best to provide useful commands by steps.
Hope these helps!
apt-cache show packagename
lists, among other things, the installed size of a package and the dependencies of a package. There's alsoapt-cache rdepends packagename
to list the packages that use that package.You might want to use the latter command and
apt-cache policy packagename
to determine if a reverse-depdendency is installed.Here is a script which does that. No machine-friendly output though.
sudo apt-get install python-apt
and you're ready to go.
Example output: