# Arch Linux System Maintainance.

In this guide we will walk through the most important practices regarding system maintainance for Linux home computers. Most of them are Arch Linux (and variants) specific but we can get ideas on how other distros can use and apply the same principles.

“No matter what you’re going through, there’s a light at the end of the tunnel.”

## Introduction

System maintainance (and software maintainance in general) is an ongoing process that requires attention and responsibility.

So in this blog post I will summarize the key actions we can take in order to keep our arch linux installation healthy, optmized and fully working.

BTW, If you are NOT using Arch yet, I have a guide explaining how to install it from scracth and also a tiny wiki with information about daily tasks, process and guides.

DISCLAIMER: There is NO better place to everything related to Arch than the Arch Linux Wiki, but in this ocassion, I would like to save us some time, and summarize and pin point the most basic/important stuff.

It is very important to have the latest version of the system up and running (including users apps and packages). I gotta say that sometimes things get broken due to the nature of the rolling release model, but since each installation is different, we are responsible for checking Arch Linux latest news in the Arch Linux website..

Once done, we can proceed to perform a system update/upgrade by running:

$sudo pacman -Syu  or if you are using any AUR helper (in my case yay): $ yay -Syu


#### Troubleshooting

• In case of package as marginal trust:
error: <package>: signature from "Someone <mail.of.someone>" is marginal trust
...
Do you want to delete it? [Y/n]


Then update the keyrings as following and run again the full system upgrade command:

$sudo pacman -Sy archlinux-keyring  ## Clean pacman cache The package manager is our source of truth when it comes to what we use in our system but its cache grows exponentially since it keeps ALL versions that we are installing/upgrading. This is of course usefull when it comes to system stability and rolling things back (by using pacman -U /var/cache/pacman/pkg/name-version.pkg.tar.gz) but it requires maintenance. Let’s perform a bunch of checks before: $ sudo ls /var/cache/pacman/pkg/ | wc -l  //cached packages
$du -sh /var/cache/pacman/pkg/ //space used  We can use paccache for this purpose, so let’s install it first (if we do not already have it): $ sudo pacman -Sy pacman-contrib


Now we can easily clean everything up and keep the latest 3 versions (default behavior):

$sudo paccache -r  ## Remove orphan packages Orphans are no more than unneeded dependencies that are a result of a package which was uninstalled. They waste storage space so they required attention too. Let’s list all the orphans in our system: $ sudo pacman -Qdtq


To remove all orphans let’s run:

$sudo pacman -Qtdq | sudo pacman -Rns -  #### Troubleshooting • In case of error: argument '-' specified with empty stdin: We do not have to worry, that means there are no orphans in our system. :) ## Remove unwanted packages Let’s list all the installed packages first in order to check whether we have software we are no longer using: $ pacman -Qei | awk '/^Name/{name=$3} /^Installed Size/{print$4$5, name}' | sort -h  We can also list the ones installed from the AUR: $ pacman -Qim | awk '/^Name/{name=$3} /^Installed Size/{print$4$5, name}' | sort -h  If we want to unistall all unneeded packages and their unused dependencies and configuration files: $ sudo pacman -Rns $(pacman -Qdtq)  In case we want to individually uninstall packages, we use this command instead: $ sudo pacman -Rns <package-name>


## Clean /home directory cache

Our cache takes a lot of space as long as we use our system, so it is a good idea to check it out and clean it up accordingly. With the following command we can check its size:

$sudo du -sh ~/.cache$ 32G  /home/fernando/.cache


If we want to clear it up, we just remove its content:

$rm -rf ~/.cache/*  ## System logs clean-up System logs are always important to fix issues and to know what is going on within our Linux distro but again, they need a bit of maintenance. Let’s first perform a system check to see how much space is being consumed by our logs: $ journalctl --disk-usage


In order to remove logs we use the same command by limiting it by time (check the man for size limit and other alternatives):

\$ sudo journalctl --vacuum-time=7d


If we want to permantely set this up by size, we can uncomment SystemMaxUse in /etc/systemd/journald.conf configuration file, to limit the disk usage used by these files by, for example: SystemMaxUse=500M in my case.

## Conclusion

That is it… at the least the minimum and basic things…. Just know, that not all the mentioned steps are mandatory and should be done in one shot one after the other, but we want to make sure we care about the healthiness of our system by from time to time giving it a bit of love.