If you administer Ubuntu desktops or servers, you know that to keep them running optimally, they do need a bit of cleaning now and then. The task isn't all that hard (especially when you know the right commands and tools), but for some, it's just another brick in an already very tall wall. To that end, it's always best to know exactly what to do with the tools at hand.
I want to offer up a few quick tips, so you can keep your Ubuntu machines running smoothly. With that said, let's get with the tips.
The best means of installation
You might be surprised to hear this, but you are much better off if you avoid installing from source. Unless it cannot be avoided, always install using the apt package manager. Why? Because with apt aware of what is installed, it is better capable of caring for the packages. Also, upgrading software installed from source can be a real nightmare—so much so, you might avoid updating altogether (and we know how wrong that is).
So, unless the only option is source, always install using the sudo apt install command. In the end, if you do have to install software from source, make sure to install it into /usr/local (as per the Free Software Foundation guidelines).
Using apt with purpose
The apt package manager has a few options you should never fail to take advantage of. These options are as follows:
To flush the local cache of retrieved package files, issue the command:
sudo apt-get autoclean
To remove any/all packages that were automatically installed (to satisfy dependencies for a package) that are no longer needed:
sudo apt autoremove
When you remove a package, to avoid leaving behind configuration files, you can use the purge option, instead of the remove option, like so:
sudo apt-get purge PACKAGENAME
Where PACKAGENAME is the name of the software to be removed.
The purge option is very useful when you want to start over with a package installation (otherwise, when you reinstall, it will pick up the previous configuration options).
If you want to roll all of the best apt options into one command, install ucaresystem-core. With this tool in place, you can, with a single command, take care of the following:
- Update the list of available packages
- Download and install updates
- Check if there are any old Linux Kernels and uninstall them
- Clear retrieved packages
- Uninstall packages that are obsolete
- Uninstall orphaned packages
- Delete settings from previously installed packages
To install ucaresystem-core, open up a terminal window and issue the following commands:
sudo add-apt-repository ppa:utappia/stable sudo apt update sudo apt install ucaresystem-core
Once installed, issue the command sudo ucaresystem-core to start the process.
Use a janitor tool
There are a number of tools that take over the janitorial process. These tools do an outstanding job of cleaning up various caches (apt, bash, Firefox, Google Chrome, Flash, LibreOffice, system, etc.). One of the most popular such tools is Bleachbit. This particular take on the janitorial tool can be found in the standard repositories, so installation is as simple as sudo apt install bleachbit. Once installed, run the tool with the command bleachbit, select what you want to clean (Figure A), and click the trash can icon.
Just make sure to use Bleachbit with caution. Until you know exactly what you're doing, avoid using this tool to delete any system caches.
Use with caution
When you're running commands that can alter your system, make sure to use them with caution. Issue the command man apt and give the apt manpage a read, so you know exactly what's going on with each command. Also, read the Bleachbit manpage with the command man bleachbit, so you have a better understanding of what the tool can do.
- How to install Countly Analytics on Ubuntu Server (TechRepublic)
- Ubuntu 17.10: Finally, an exciting Ubuntu release (TechRepublic)
- How to speed up DNS caching on Linux machines with dnsmasq (TechRepublic)
- An introduction to the Linux home directory (TechRepublic Video)
- Canonical asks users' help in deciding Ubuntu Linux desktop apps (ZDNet)
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.