See all Debian/Ubuntu Linux related FAQ
In Debian and Ubuntu Linux, an “rc” status package means the package has been uninstalled, but its configuration files remain on the disk and take up space. Sometimes, certain directories are also in the /var/ directory. When you type the sudo apt remove pkg1 command, it deletes most of the data, but config files are left alone in case you reinstall that package again. You can free up disk space by removing unwanted config files.

Synopsis: You can use the “apt list '~c'” command to list and sudo apt purge '~c'” command to delete all packages marked “rc” state (removed but config files left on the disk) on your Debian or Ubuntu Linux using the APT-GET.
Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Linux terminal
Category Package Manager
OS compatibility Debian Linux Mint Pop!_OS Ubuntu
Est. reading time 4 minutes

APT package status codes to view or uninstall packages marked as “rc”

Before you remove package config files, you need to understand the package status codes for installed or uninstalled. Run the following dpkg command or dpkg-query command $ dpkg -l 'libc6*' 'nginx*' thunderbird
# OR #
$ dpkg-query -l 'libc6*' 'nginx*' 'thunderbird*'

Here is what I get on my Ubuntu Linux version 20.04:

| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                      Version                           Architecture Description
ii  libc6:amd64               2.31-0ubuntu9.15                  amd64        GNU C Library: Shared libraries
ii  libc6:i386                2.31-0ubuntu9.15                  i386         GNU C Library: Shared libraries
un  libc6-amd64               <none>                            <none>       (no description available)
ii  libc6-dbg:amd64           2.31-0ubuntu9.15                  amd64        GNU C Library: detached debugging symbols
ii  libc6-dev:amd64           2.31-0ubuntu9.15                  amd64        GNU C Library: Development Libraries and Header Files
un  libc6-i386                <none>                            <none>       (no description available)
un  libc6-i686                <none>                            <none>       (no description available)
un  libc6-xen                 <none>                            <none>       (no description available)
un  libc6.1-dev               <none>                            <none>       (no description available)
ii  nginx                     1.18.0-0ubuntu1.4                 all          small, powerful, scalable web/proxy server
ii  nginx-common              1.18.0-0ubuntu1.4                 all          small, powerful, scalable web/proxy server - common files
ii  nginx-core                1.18.0-0ubuntu1.4                 amd64        nginx web/proxy server (standard version)
un  nginx-doc                 <none>                            <none>       (no description available)
un  nginx-extras              <none>                            <none>       (no description available)
un  nginx-full                <none>                            <none>       (no description available)
un  nginx-light               <none>                            <none>       (no description available)
rc  thunderbird               1:102.4.2+build2-0ubuntu0.20.04.1 amd64        Email, RSS and newsgroup client with integrated spam filter
un  thunderbird-gnome-support <none>

The first three columns of the output show the desired action, the package status, and errors, in that order. Let’s break it down. Desired action are as follows:

  • u : Unknown
  • i : Install
  • h : Hold
  • r : Remove
  • p : Purge

Package status can be any one of the following:

  • n : Not-installed
  • c : Config-files
  • H : Half-installed
  • U :Unpacked
  • F :Half-configured
  • W :Triggers-awaiting
  • t :Triggers-pending
  • i :Installed

Error flags:

  • <empty> : (none)
  • R : Reinst-required

So the the rc means:

  1. r : The package is marked for removal or already removed.
  2. c : The configuration files are still present on the disk eating up disk space.

Step 1 – Finding all packages in the “rc” status

Let us see nvidia package status, run:
$ dpkg --list | grep nvidia

rc  libnvidia-compute-510:amd64                   510.85.02-0ubuntu0.20.04.1                      amd64        NVIDIA libcompute package
rc  libnvidia-compute-520:amd64                   525.60.11-0ubuntu0.20.04.2                      amd64        Transitional package for libnvidia-compute-525
rc  libnvidia-compute-525:amd64                   525.125.06-0ubuntu0.20.04.3                     amd64        NVIDIA libcompute package
rc  nvidia-compute-utils-510                      510.85.02-0ubuntu0.20.04.1                      amd64        NVIDIA compute utilities
rc  nvidia-compute-utils-525                      525.125.06-0ubuntu0.20.04.3                     amd64        NVIDIA compute utilities
rc  nvidia-cuda-toolkit                           10.1.243-3                                      amd64        NVIDIA CUDA development toolkit
rc  nvidia-dkms-510                               510.85.02-0ubuntu0.20.04.1                      amd64        NVIDIA DKMS package
rc  nvidia-dkms-520-open                          520.56.06-0ubuntu0.20.04.1                      amd64        NVIDIA DKMS package (open kernel module)
rc  nvidia-dkms-525                               525.125.06-0ubuntu0.20.04.3                     amd64        NVIDIA DKMS package
rc  nvidia-kernel-common-510                      510.85.02-0ubuntu0.20.04.1                      amd64        Shared files used with the kernel module
rc  nvidia-kernel-common-525                      525.125.06-0ubuntu0.20.04.3                     amd64        Shared files used with the kernel module

You can also use the apt command or apt-get command as follows:
$ apt list '~c'

Getting a list of packages marked as ‘rc’ on Debian or Ubuntu Linux usint APT-GET

Click to enlarge

Step 2 – Removing packages marked “rc” on Debian / Ubuntu Linux

WARNING! Watch package names carefully before removing them. Do not remove required packages. Always keep verified backups. The nixCraft or author is not responsible for data loss.

Now I can remove those unwanted Nvidia packages one-by-one using the APT as follows. You must pass the --purge< as follows:
$ apt --purge remove libnvidia-compute-510:amd64 libnvidia-compute-520:amd64 libnvidia-compute-525:amd64 nvidia-compute-utils-510 nvidia-compute-utils-525 nvidia-cuda-toolkit nvidia-dkms-510 nvidia-dkms-520-open nvidia-dkms-525 nvidia-kernel-common-510 nvidia-kernel-common-525
Another option is to write the following shell kung-fu with help of grep command and awk command:
➀{usr@box1:~}$ pkg_list=$(dpkg --list | grep nvidia | awk '{ print $2}')
②{usr@box1:~}$ echo "$pkg_list"
➂{usr@box1:~}$ sudo apt --purge remove $pkg_list

➀{usr@box1:~}$ pkg_list=$(dpkg --list | awk '$1 == "rc" {print $2}')
②{usr@box1:~}$ echo "$pkg_list"
➂{usr@box1:~}$ sudo apt --purge remove $pkg_list

Let us break down the shell kung-fu:

pkg_list=$(dpkg --list | awk '$1 == "rc" {print $2}')

  1. dpkg --list : This command lists all installed packages along with their status and pass outputs to the awk.
  2. awk '$1 == "rc" {print $2}' : This awk command filters out only those lines where the first column indicates a package is in the ‘rc’ state, and prints the package name from the second column. This filtered list of packages is stored in the shell variable named pkg_list.

echo "$pkg_list"

  1. Use the echo command or printf command to prints out the list of packages obtained using the dpkg --list | awk ... command. This is for your verification and to avoid deleting unwanted packages.

sudo apt --purge remove $pkg_list

  1. sudo : Now you are doing sysadmin task and you need superuser privileges to erase packages.
  2. apt --purge remove $pkg_list: This command removes packages listed in the $pkg_list shell variable. The --purge flag is used to remove not only the packages but also their configuration files. The $pkg_list is expanded to include the list of package names obtained earlier using the dpkg --list | awk ... command.

Checking free disk space on Linux

Before executing the apt command you may wish to run the df command or du command to check free disk space on your Linux box. For example:
$ df -H /
Now do it:
$ sudo apt --purge remove $pkg_list

How to remove all rc packages using APT command line at once on a Debian or Ubuntu Linux

Click to enlarge

The latest version APT on a Debian or Ubuntu also supports the following syntax:
$ sudo apt purge '~c'

Summing up

You can use the any one of the following command to list packages in the ‘rc’ state:
$ apt list '~c'
# OR
$ dpkg --list | grep nvidia | awk '{ print $2}'

And remove them using any one of the following commands:
$ sudo apt purge pkg_name
# OR
$ sudo dpkg -P pkg_name

For bulk packages removal in the ‘rc’ state try:
$ sudo apt --purge remove $(dpkg --list | awk '$1 == "rc" {print $2}')
For more info see the following manual pages using the man command or help command:
$ man apt
$ man apt-get
$ man dpkg
$ man dpkg-query

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

0 comments… add one

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.