Ubuntu – why `dpkg -l | grep package` is showing a package after being purged

aptdpkgpackage-managementuninstall

To uninstall a package (Ex: tor) installed from repository one should use

sudo apt-get remove tor

I did this but dpkg -l | grep tor shown something against the package. Next I try

sudo apt-get purge tor

But when I check dpkg -l | grep tor I got,

reza@reza-N43JM:/$ dpkg -l tor    
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-==============-==============-============================================
un  tor            <none>         (no description available)

I think when I uninstall any package I should not get anything in dpkg -l list. Is it true? Or apt-get remove or purge does another work but not uninstall?

Best Answer

Note the first two letters of the output of dpkg -l tor which says un

u: Unknown (an unknown state)
n: Not- The package is not currently installed

sometimes dpkg keeps such entries for references. To remove those problematic entries, run in terminal,

sudo dpkg --clear-avail

From man dpkg

--clear-avail
          Erase  the  existing  information  about   what   packages   are
          available.
Related Question