To remove a package in a Debian-based system using the apt package manager, you can use the following commands:
Simple Removal
This command removes the package but keeps its configuration files:
sudo apt remove package-name
Complete Removal
If you want to remove the package along with its configuration files, use the purge command:
sudo apt purge package-name
Clean Up Unnecessary Packages
After removing a package, it's a good practice to clean up any packages that were automatically installed as dependencies but are no longer needed:
sudo apt autoremove
Example
For example, to remove the neofetch package, you would run:
sudo apt remove neofetch
Or, to completely remove it along with its configuration files:
sudo apt purge neofetch
After removal, you can verify that the package has been successfully removed by trying to run it:
neofetch
You should see an error message indicating that the command is not found.
