System Cleanup and Maintenance

D

DevynCJohnson

Guest
It is important to keep computer systems running at optimal performance. However, the Linux system may accumulate cache and unneeded files, need updates, retain old data, etc. Thankfully, there are many ways Linux users can clean their system and maintain the best performance. In addition, there are ways to optimize a freshly installed system.

The first way to better maintain and optimize the system is to properly take care of the package management system. Remove (or disable) any repositories/PPAs that are not needed and not used. If the users on the system never download source code from the repos, then disable all "Source" repositories and PPAs. Doing so reduces the size of the local indexes that are created when updating the repo list (such as "apt-get update"). Also, this reduces the network usage since less data and servers need to be obtained and inquired.

Remove and purge any packages and software that are no longer needed or used. Also, remove the residual configuration of packages that are not currently installed. On Debian-based systems, it may help to use Synaptic which is a GUI interface to the package management system. Synaptic can group the packages by "Status" which makes this process a lot easier. Other distros may have similar GUI interfaces.

Many Linux systems have many documentation packages (*-doc) that users may never read/use. Usually, these can be removed unless a package depends on them. Similarly, developer packages (*-dev) are not needed unless a user is a developer or another package requires them. In addition, make sure the system is configured to not treat "suggested" and "recommended" packages as dependencies. This can be set in the preferences of Synaptic (if used by the system). Otherwise, go to /etc/apt/apt.conf.d/ and open ./00aptitude and ./99synaptic (if present) and add the below code to the file. However, if that line is present, be sure to set its value to “false”.
Code:
APT::Install-Recommends "false";

A helpful utility to have is "Bleachbit" ( http://bleachbit.sourceforge.net/ ) which is usually in the default repositories. With Bleachbit, users can easily remove logs, cache, unneeded man-pages (such as ones of a different language), etc. For instance, numerous packages includes its manual page (man page) in multiple languages. Obviously, if the user only speaks a few languages, then having a man page in fifty or more different languages wastes disk space. In Bleachbit's preferences, users can choose which languages to keep. Then, Bleachbit can remove the rest. Some users may save fifty megabytes or more just in this trick alone.

Bleachbit has other features that can optimize and reduce the size of various programs and parts of the system. Each tool in Bleachbit has a description in the program. Bleachbit can remove logs, thumbnails, web-browser cookies, etc. Be sure to check out and use Bleachbit (both with and without Root-privileges). However, be careful about the tools that are used. Otherwise, data may be lost that the user intended on keeping.

For systems that are only updated on rare occasions or less than a monthly basis may want to entirely clear the whole package management cache and repo databases/indexes. Bleachbit can also do this action.

Thumbnails can take up a lot of space depending on use. Bleachbit can clear thumbnails or users can use the free script below (copy and paste into an empty file).

Code:
#!/bin/sh
# -*- coding: utf-8 -*-
# vim:fileencoding=utf-8
# Created by Devyn Collier Johnson
# <[email protected]>

# Version 2015.02.20
# Public Domain (CC0)
# https://creativecommons.org/publicdomain/zero/1.0/
# http://creativecommons.org/about/cc0

rm -rf ~/.thumbnails || rm -rf ~/.thumbnail || true
rm -rf ~/.cache/thumbnails || rm -rf ~/.cache/thumbnail || true

Also, when uninstalling programs and purging all configuration files, the package manager does not remove configuration files and cache that is stored in the home directory of users. The cache and config files maybe hidden files in the top of a user's home directory (such a ~/.firefox/). However, most cache is in the ~/.cache/ directory and the configuration files are in ~/.config/. Some temporary files, cache, and settings are stored under ~/.local/share/. Typically, the trashcan, recycle bin, etc. is stored under ~/.local/share/Trash/. Be sure to browse these folders.

The system can be made to boot up a little faster if unneeded services and kernel module packages are removed. For example, many users can use the package manager to install "btrfs-tools" which will add a service that starts between boot-time and the login screen. This service takes a little time to perform some tasks. If the user does not have or use the B-Tree Filesystem (btrfs), then this package should be uninstalled.

Some advanced users may benefit from installing "bum" (Boot-Up Manager). This GUI utility allows admins to choose which services to disable or enable. If fewer services appear during boot-time, then the boot-time will take less time. However, be sure that needed or desired services are not disabled. In addition, the system will have more free memory if less services are running. Also, users may want to see if they have a "start-up manager"; if not, then get one. A start-up manager allows users to disable and enable the start-up of services that begin when the user logs into the system. However, not all services will appear in the start-up manager until a special command is run with Root-privileges to make "hidden services" visible. The command is
Code:
sed -i 's/NoDisplay=true/NoDisplay=false/g' /etc/xdg/autostart/*.desktop

On systems that use Gconf, a special utility called "gconf-cleaner" can be used to remove unneeded keys and entries. The keys and entries that are removed are ones that were added when a program was installed, but not deleted after the package's removal.
Gconf-Cleaner.jpg


There are many other methods of optimization and maintenance, but these are some of the most important.

Further Reading
 

Attachments

  • slide.jpg
    slide.jpg
    43.7 KB · Views: 47,306
Last edited:


There are cleaners galore available for Debian.

deborphan and its GTK+ front-end find unused libraries and orphaned packages. debfoster shows you packages that have the most dependencies. localepurge removes unneeded locales and this can save huge space on your hard drive.

Also you may want to run apt-get autoremove; apt-get clean and apt-get autoclean.

If you are using Synaptic there is also a Residual Config filter which shows you retained configuration files for removed packages.
 
If you are on a Systemd Distribution then you can use
Code:
systemd-analyze blame
to find the systemd services that are taking the longest to startup. I have found this very useful in the past.

Also, @DevynCJohnson , would you bold that waring about Bleach Bit?
 

Staff online

Members online


Top