Maintenance and update script for Debian 12 / MX 23

Maintenance and update script for Debian 12 / MX 23

Maintenance and update script for Debian 12 / MX 23

During all these years, we have shared practical and useful tutorials on using the Linux Terminal, its most basic and essential commands, and how to use all this together to create various Bash Shell Scripts for certain functions or activities. Being 2 emblematic examples, one on a Backup script and another about a Maintenance and update script of the installed Debian base operating system. Which, most likely, were at the time a base that could be perfected or improved for many in their respective GNU/Linux Distros, based on Debian or not.

And although, certainly, much progress has been made in terms of graphic applications, automatable or not, for home computers and servers, in these 2 important tasks, the truth is that, Many of us still prefer to use the terminal (console) for important activities such as updating our operating system in depth, whether manually and assisted or fully automated. Therefore, today we will show you some small command commands for GNU/Linux Distros based on Debian 12 that you could include in your current or next Maintenance Script.

Maintenance and Update Script on GNU / Linux

Maintenance and Update Script for GNU/Linux 2018

And, before starting this tutorial on useful command lines to create or improve your own «Maintenance and update script for Debian GNU/Linux 12» or other similar ones, we recommend you explore the previous related post, at the end of it:

Maintenance and Update Script on GNU / Linux
Related article:
How to do a GNU / Linux Maintenance using a Script?

Commands to create maintenance and update script

Commands to create maintenance and update script

Useful command commands for a maintenance and update script for Debian

Our first recommendation is, and just in case, said free and open operating system based on Debian GNU/Linux have the Bleachbit application already installed, and the user has it very well configured and optimized to graphically perform the maintenance (cleaning) of their operating system, executing manually or within a script the following command order to:

Cleaning the user's (home) directory and the rest of the operating system

bleachbit --preset --preview;  bleachbit --preset --clean
sudo bleachbit --preset --preview;  sudo bleachbit --preset --clean

Cleaning the operating system using the APT package manager

sudo apt update; sudo update-apt-xapian-index; sudo apt upgrade; sudo apt install -f; sudo apt install --fix-broken; sudo apt autoclean; sudo apt autoremove; sudo apt autopurge

Fix bugs using the DPKG package manager

sudo dpkg --configure -a;

Update GRUB, Initramfs and the operating system Menus

sudo update-grub; sudo update-grub2; sudo update-menus; sudo update-initramfs -u

Up to this point, the more basic or essential command orders to use. Now, the only thing left to do is decide if we want them to be used within a Script in a linear (sequential) manner with or without user intervention, or through the necessary code so that the Script asks us if we want to execute each command order separately. or in blocks. That is at the discretion of each one. Also, they could be incorporated into a GUI Script instead of CLI for selection and execution via clicks, as I once showed in the following publication.

These lines of code or other similar ones could also be useful, depending on each person's taste and need:

View % storage space usage for each mount point

sudo df -h

See in alphabetical order the size occupied by each partition

sudo du -hs /* | sort -k 2

Clear the user's Terminal history

history -c

Get a log of all installed packages sorted alphabetically

sudo apt list --installed > $HOME/listado-paquetes-instalados-apt-dpkg.txt 

Get a record of all installed packages sorted by size in MB occupied

sudo dpkg-query -Wf '${Installed-size}\t${Package}\n' | column -t | sort -k1 > $HOME/listado-paquetes-instalados-peso-milagros.txt

Basic and common command commands for GNU/Linux Distros based on Debian

Basic and common command commands for GNU/Linux Distros based on Debian

If you want to complement, improve or perfect your Maintenance and update script for Debian and other similar ones, below is a small list with the most basic and common orders based on APT, DPKG and UPDATE:

apt

  1. apt update: Update repository package lists.
  2. apt upgrade: Update packages from repositories safely.
  3. apt full-upgrade: Update packages from the repositories completely.
  4. apt dist-upgrade: Upgrade the current OS version to the next available one.
  5. apt install -f: Solve problems installing packages and their dependencies.
  6. apt install --fix-broken: Solve problems related to broken packages.
  7. apt remove nom_paq: Delete packages. Also, it can be used without the name.
  8. apt autoremove: Automatically remove all unused packages.
  9. apt purge nom_paq: Remove packages completely. Also, it can be used without a name.
  10. apt autopurge: Automatically and completely remove all unused packages.
  11. apt clean: Delete all ".deb" packages, downloaded in the package store directory.
  12. apt autoclean: Removes all packages from the package store, which can no longer be downloaded.
  13. apt install nom_paq_repo: Install a certain package from the repository by name.
  14. apt install /dir_paq/nom_paq.deb: Install a downloaded package by name.
  15. apt list *nom_paq*: List packages by matching a search pattern.
  16. apt list --upgradeable: List the packages available for updating.
  17. apt show nom_paq: Show the data and relevant information of a package from the repository.
  18. apt search nom_paq: Show existing packages that match the search pattern.
  19. apt edit-sources: Open, in edit mode, the main software sources (repositories) file.

dpkg

  1. dpkg -i /dir_paq/nom_paq.deb: Install a downloaded package by name.
  2. dpkg --configure -a: Finish configuring all unpacked and discontinued packages.

Update

  1. update grub: Update the GRUB (Multiple Boot Loader v1) installed on the disk/partition.
  2. update grub2: Update the GRUB (Multiple Boot Loader v2) installed on the disk/partition.
  3. update-menus: Automatically generate and update the content of the Menu System.
  4. update-alternatives --all: Manage all OS symbolic link information.

Something important to keep in mind is that most of the commands shown with the current package manager «apt», have their equivalent in the previous package managers «apt-get" Y "aptitude». Also, with the modern package manager «Nala». And of course, with the respective package managers of each GNU/Linux Distro other than Debian, such as Arch, Fedora and many others. Therefore, some can be replaced if necessary.

How to make a Data Backup in Equipment using Shell Scripting?
Related article:
How to make a Data Backup in Equipment using Shell Scripting?

Roundup: Banner post 2021

Summary

In short, we hope that you are terminal command commands that we have shown you today, and suggested or recommended, can directly serve you to create or improve your own «Maintenance and update script on Debian» or other similar ones, based on it or not. Otherwise, that is, if you prefer the use of graphical interfaces, you can without any problem use third-party tools such as bleachbit o Stacer, and most of the utilities of each GNU/Linux Distro available for it. For example, I use MX Linux, I can use MX Cleanup and MX Updater.

Lastly, remember visit our «homepage» in Spanish. Or, in any other language (just by adding 2 letters to the end of our current URL, for example: ar, de, en, fr, ja, pt and ru, among many others) to learn more current content. And also, you can join our official channel Telegram to explore more news, guides and tutorials. And also, has this group to talk and learn more about any IT topic covered here.