How to remove unused packages with apt?
After packages are upgraded on systems running apt, the package manager have mark some packages as no longer required. Typically this happens when a dependency on another package has been removed, or another package supersedes the existing package. In that case the package becomes an orphan and no longer provides specific function another package or to the system.
Run the apt command with the autoremove subcommand to check for orphaned packages and remove them.
apt autoremove