Locating the ‘top’ Command Package in Linux (CentOS/RHEL): util-linux vs procps Analysis


15 views

When working with Linux performance monitoring, the top command is one of the first tools sysadmins and developers reach for. However, its package location varies across distributions. In CentOS/RHEL systems, you'll find it in the procps-ng package, not util-linux or coreutils as some might assume.

To identify which package provides top on your CentOS system:

rpm -qf $(which top)
# Sample output: procps-ng-3.3.10-26.el8.x86_64

For Debian-based systems, you'd use:

dpkg -S $(which top)
# Sample output: procps: /usr/bin/top

When creating deployment scripts or container images, explicitly declaring dependencies becomes crucial. If you're writing a script that requires top, your package installation command should be:

# For CentOS/RHEL:
yum install procps-ng

# For Debian/Ubuntu:
apt-get install procps

Many developers prefer alternative implementations like htop. Here's how to configure an alias in your .bashrc:

# Check if htop exists, fall back to top
if [ -x "$(command -v htop)" ]; then
    alias top='htop'
else
    echo "Consider installing htop for enhanced features:"
    echo "  yum install epel-release && yum install htop"
fi

When building Docker images, your Dockerfile should explicitly include the required package:

FROM centos:8
RUN yum install -y procps-ng \
    && yum clean all
CMD ["top"]

The package contains other essential utilities you might need:

  • vmstat - Virtual memory statistics
  • free - Memory usage information
  • ps - Process status (though some distributions put this in procps)

If you encounter a "command not found" error, verify the package is installed:

# CentOS/RHEL 7/8:
yum list installed | grep procps

# CentOS Stream/RHEL 9:
dnf list installed | grep procps

To see all files provided by the package:

rpm -ql procps-ng

On CentOS and RHEL systems, the top command is actually distributed through the procps-ng package, not util-linux or coreutils as one might initially assume. This often causes confusion because:

  • Basic system utilities are typically split between util-linux and coreutils
  • System monitoring tools frequently have different package dependencies

To confirm which package provides top on your CentOS system:

# Method 1: Using rpm
rpm -qf $(which top)

# Method 2: Using yum/dnf
dnf provides */top
# or for older CentOS versions:
yum whatprovides */top

Example output should show:

procps-ng-3.3.10-26.el8.x86_64 : System and process monitoring utilities
Repo        : @System
Matched from:
Filename    : /usr/bin/top

If you need to install or reinstall the package:

# Install procps-ng
sudo dnf install procps-ng

# Verify installed version
rpm -q procps-ng --info

# Check all utilities provided by the package
rpm -ql procps-ng | grep bin/

While discussing top, it's worth mentioning other system monitoring utilities that often coexist in the same ecosystem:

  • vmstat - Virtual memory statistics
  • free - Memory usage information
  • ps - Process status (though modern systems often have this in procps-ng)
  • htop - Enhanced alternative (requires separate installation)

The procps-ng package is actually a new generation of the original procps package, with improvements including:

  • Better multiprocessor support
  • Improved memory reporting
  • Enhanced command-line options
  • Regular security updates

For developers working on system monitoring applications, understanding these package dependencies is crucial when:

  • Building minimal container images
  • Creating installation scripts
  • Troubleshooting missing commands
  • Developing system monitoring tools