A Python script to completely remove CUPS (Common Unix Printing System) and associated services from Linux systems.
- Removes CUPS installations from both APT and Snap
- Stops and disables CUPS-related systemd services
- Cleans up residual files and directories
- Handles errors gracefully to ensure complete removal
- cups.service
- cups.socket
- cups.path
- cups-browsed.service
- cups-proxyd.service
- cups
- cups-bsd
- cups-client
- cups-common
- cups-core-drivers
- cups-daemon
- cups-filters
- cups-filters-core-drivers
- cups-ppdc
- cups-server-common
- cups-browsed
- cups
- cups-browsed
- cups-proxyd
- /etc/cups/
- /var/spool/cups/
- /var/cache/cups/
- /var/log/cups/
- /var/lib/cups/
- /var/snap/cups/
- Python 3
- Root privileges
- Linux system with systemd
- Clone this repository or download the
cups.pyscript. - Make the script executable:
chmod +x cups-free.py
Run the script as root:
sudo ./cups-free.py- Systemd Services: The script checks if each CUPS-related service is active and only attempts to stop or disable it if it is running. If a service is already inactive or not loaded, the script skips the action without errors.
- APT Packages: The script removes all CUPS-related packages installed via APT and cleans up dependencies using apt-get autoremove.
- Snap Packages: The script removes CUPS and its associated Snap packages if installed.
- File Cleanup: It deletes all remaining files and directories related to CUPS, ensuring no residual configuration or data remains.
The script includes robust error handling:
- Continues execution if services are not active or loaded
- Logs errors during package removal or file deletion without stopping
- Gracefully handles missing Snap packages
This script will completely remove CUPS and all associated components. Ensure you don't need printing services before running it.
- Check terminal output for any error messages
- Ensure an active internet connection for package removal
- If a specific component fails to remove, you can manually remove it using the appropriate system commands
Contributions to improve the script are welcome. Please submit a pull request or open an issue to discuss proposed changes.
This script is open-source and available under the MIT license. Feel free to modify and distribute it as needed.