For Debian (.deb) :-
dpkg with -r option removes the installed package.
sudo dpkg -r <pkgname>

Now list the package and check the status.
dpkg -l | grep '<pkgname>'
Here,
“rc” stands for ‘removed ok config-files’. The remove action didn’t purge the configuration files.
The status of each installed package will be available in /var/lib/dpkg/status
The following command is used to purge the package completely.
sudo dpkg -P <pkgname>
For RPM :-
rpm -e <pkgname>