Skip to content

Arch Linux Maintenance Documentation

Generic commands for me to use.

1. Check disk usage and free space

To see how much space is used and available on each partition:

df -h

For more detailed usage on individual directories:

du -sh /*

To check specific folder usage, like your home directory:

du -sh /home/USER

2. Delete files in Trash

To clear the Trash:

rm -rf ~/.local/share/Trash/files/*

3. Remove unused packages and clean package cache

To remove orphaned packages (packages that were installed as dependencies but are no longer required):

sudo pacman -Rns $(pacman -Qdtq)

To clean the pacman package cache, removing old versions of packages:

sudo pacman -Sc

To remove all cached packages (careful with this as it removes all cached versions):

sudo pacman -Scc

4. Update the system

To update the system and all packages:

sudo pacman -Syu

5. List installed packages

To list all installed packages:

pacman -Q

To list only explicitly installed packages (packages you manually installed):

pacman -Qe

6. Check for broken packages

Sometimes, an update might break something. To check if there are any broken or incomplete packages:

sudo pacman -Qk

7. Remove unnecessary logs

Log files can accumulate over time. To remove systemd logs (be cautious, as this might remove useful logs):

sudo journalctl --vacuum-size=100M

To clear all logs, set a retention period (e.g., 1 week):

sudojournalctl --vacuum-time=1w

8. Remove unused dependencies (after uninstalling software)

When you remove software, there may be leftover dependencies that were installed with it but are no longer needed. Clean these up with:

sudo pacman -Rns $(pacman -Qdtq)

9. System Cleanup and Optimizing

You can also use debt of space in hidden configuration files or directories. This command cleans some space from orphaned packages or unneeded files (it’s safe to run occasionally but make sure to review packages first):

sudo pacman -Qdtq | sudo pacman -Rns -

10. Check your system for errors

Sometimes file systems can develop errors. You can check and repair them (if needed):

sudo fsck -A

For specific file systems (e.g., if you want to check /home):

sudo fsck /dev/sda3

11. Remove old kernels

If you’re using linux-lts or other kernel versions, they can take up a lot of space. Remove unused or older kernels:

sudo pacman -R linux-lts linux-lts-headers

12. Rebuild package database

Sometimes, the package database can become corrupt. If you face issues with package installation or updates, rebuild it:

sudo pacman -Syyu

13. Clear the font cache

To clear font cache and refresh it:

sudo fc-cache -f -v

14. Check running processes

To view the running processes and resource usage on your system:

top

Or for a more detailed view:

htop

15. Uninstall a package

If you need to remove a package completely (including dependencies that were installed with it):

sudo pacman -Rns <package_name>

16. View system logs

To see detailed logs of system activities, including errors or other logs:

sudo journalctl -xe

17. Check for available system updates

To check if there are updates without actually installing them:

sudo pacman -Qu

18. Checking and cleaning memory usage (swap)

To view swap usage:

swapon --show

To turn off swap (useful for troubleshooting or cleanup):

sudo swapoff -a

19. Free up system memory (clear cache)

To clear cached memory:

sudo sysctl vm.drop_caches=3
Published incommandslinux

Comments are closed.