How to List Installed Packages by Size on CentOS/Fedora/Arch Linux
Abstract: you can use the 'grep' command to retrieve the installed size of a package. The syntax is as shown below. dnf install package-name | grep -i "Installe
Sometimes, you may need to keep track of your system's hard drive space especially if it's a cloud instance that's hosted on Amazon EC2, Linode, Digital Ocean or on your physical server. You may be tempted to think that it's only files and folders that can fill up your space but equally, some installed packages can take up quite a huge volume of space on your drive. In this article, we take a look at how you can find the size of installed packages on RHEL / CentOs 7, Fedora and Arch Linux.
Show size of installed packages RHEL / Centos 7To find out how much disk space packages in your system occupy, run the command below
rpm -qa --queryformat '%10{size} - %-25{name} \t %{version}\n' | sort -n
From the command above, the '%10{size}' option aligns the size of the package to the right with a padding of 10 characters. The '%-25{name} aligns the name of the package to the left, padded to 25 characters. The '%{version} indicates the version and 'sort -n' flag sorts the packages according to size from the smallest to the largest in bytes.
Sample output
3700 - crontabs 1.11
3979 - systemd-sysv 219
4067 - dracut-config-rescue 033
5134 - perl-macros 5.16.3
5711 - selinux-policy 3.13.1
7732 - python-rhsm-certificates 1.19.10
8141 - perl-parent 0.225
11466 - fipscheck-lib 1.4.1
13981 - nss-sysinit 3.28.4
14193 - python-backports-ssl_match_hostname 3.4.0.2
16431 - perl-Text-ParseWords 3.29
16545 - hardlink 1.0
17134 - python-magic 5.11
18640 - kernel-tools-libs 3.10.0
19449 - hostname 3.13
The command will also work for Fedora 22 and later systems and give a similar output.
Find the size of installed packages in ArchLinuxArchLinux comes with a utility tool called pacgraph that enable a user to output a list of installed packages and the size they occupy in the system. To install pacgraph, run the command below
pacman -S pacgraph
After the installation completes, run the pacgraph command to display the output.
pacgraph
Sample Output
Autodetected Arch.
Loading package info
Total size: 730MB
114MB linux
103MB libtool
84MB pacgraph
40MB imagemagick
25784kB ppl
22264kB nmap
17295kB pkgfile
If you are running a GUI instance of ArchLinux, the command will output a PNG or an SVG file to visually represent the results of package installation sizes.
Find the size of installed packages in Fedora using dnfFor Fedora 21 and later distributions, dnf package manager is used in package management. To find out the size of installed packages, run the dnf command below
dnf info package-name
The command will also display additional information about the package e.g Name, Version, release, repo etc. For example, if we want to investigate the space samba package occupies, run
dnf info samba
Output
Available Packages
Name : samba
Arch : x86_64
Epoch : 2
Version : 4.1.20
Release : 1.fc21
Size : 558 k
Repo : updates
Summary : Server and Client software to interoperate with Windows machines
URL : http://www.samba.org/
License : GPLv3+ and LGPLv3+
Description : Samba is the standard Windows interoperability suite of programs
: for Linux and Unix.
From above, we can see that the size the package occupies is 558 kilobytes.
Alternatively, during installation of a package, you can use the 'grep' command to retrieve the installed size of a package. The syntax is as shown below.
dnf install package-name | grep -i "Installed size"
To find the size cacti package would take up on the disk, run
dnf install cacti | grep -i "Installed size"
Output
Installed size: 10 M
Wrapping up, You are welcome to try out the commands and give us some feedback. Thank you.