apt System Maintenance Script

Mark GrantMark Grant
2 min read

There is nothing clever about this script, it is really just a helper script which saves typing.

The APT system used by Debian and it’s derivatives (Ubuntu, Raspbian, etc.) mainly revolves around updating the package lists and upgrading installed packages. i.e.

sudo apt-get update

sudo apt-get upgrade

Over time the system can get polluted with obsolete packages in the cache and installed packages which are no longer required. The helper script discussed here addresses these subjects.

Script Design

The script runs a number of apt-get commands

apt-get upgrade

The first command run is upgrade which upgrades installed packages if a newer version is available.

apt-get autoclean

This removes packages from the cache which can no longer be downloaded.

apt-get check

This updates the package cache and checks for broken dependencies.

apt-get autoremove

This removes packages which were automatically installed to satisfy a dependency for another package being installed and are no longer required.

And that is it!

Installing the agmaint package

The APT maintenance helper script package is called agmaint.
To prevent bitrot of this blog, please follow the installation instructions for your distribution at the project wiki:-
https://github.com/m-grant-prg/agmaint/wiki

Running the script

The script should be run regularly, I run it every day but less frequently is OK. You have to run the script with elevated privileges:-

sudo agmaint.sh

Authoritative sources

The authoritative source for this project is held on GitHub at:-

The code repository:- https://github.com/m-grant-prg/agmaint

The wiki:- https://github.com/m-grant-prg/agmaint/wiki

To view or raise issues please visit:- https://github.com/m-grant-prg/agmaint/issues

My Projects

0
Subscribe to my newsletter

Read articles from Mark Grant directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mark Grant
Mark Grant

I have spent many years in IT starting as a programmer in C and Basic then moving into general, data centre and infrastructure management. I am now back writing software mostly in bash and C. These are usually in the form of AutoTools projects which are often then packaged for various Linux distributions such as Debian, Raspbian, Ubuntu, Fedora and openSUSE.