Is there a way to compute the size of all files that are not managed by the package manager? For example all stuff that is in /opt
, /var/
, /usr/local
, etc.
I would like to find out how much disk space is used by installed packages and compare that to the disk space that is used by unmanaged files.
Update: My question is different from What is taking up so much space on my disk, beside the filesystem?
I know that on apt/dpkg
based distributions like Debian and Ubuntu the package manager, e.g dpkg keeps track of all files that are installed with it. We can use tools like dpkg-query
to get information abotu these packages.
For example I tried to get the size of all installed packages with this command:
dpkg-query -W --showformat='${Installed-Size}\n' | \
sort -k1,1n |awk '{s+=$1} END {print s}'
but I believe this is not correct, because the calculated sum is very close to the total occupied space in /
and I have several GB of files stored under /opt
that should not count towards this result.
Essentially what I am looking for is some tools that can distinguish between files installed by the package manager, and all the other files which are on the root file system but are not managed by the package manager.
When my disk is starting to fill up I would like to know, if I:
a) Installed too many packages or b) There are too many other files on the file system that take up space.
So I would like to get something like the following information about my root file system:
56GB of 60GB are used on '/':
* 32GB are used by installed packages
* 24GB are used by other files
When I use a tool like baobab
, it does not distinguish between package manager installed files and any other file.
du -sh /opt /var /usr/local
will show you the size of every directory you're interested in – 13dimitar Jan 18 '17 at 12:15