Pacman & Paru Commands Reference

Full System Update and Upgrade

# Update the system package lists and re-install keyrings only if needed
sudo pacman -Sy archlinux-keyring chaotic-keyring endeavouros-keyring --noconfirm  --needed

# Update the system package lists and install all package updates without confirmation
paru -Syu --noconfirm --needed

# echo out number of packages stored in the cache:
echo $(sudo ls /var/cache/pacman/pkg/ | wc -l) packages in cache

# clear out paru/pacman caches for ALL installed/uninstalled packages
( echo "y"; echo "y" ) | sudo pacman -Scc

Update pacman packages with no confirmation

paru -Syu --noconfirm

--needed is used to upgrade packages only if newer versions are available or if they are not already installed. This flag ensures that the system only downloads and installs necessary updates, saving time and bandwidth.

pacman -Sy synchronizes the package database once a day pacman -Syy forces a complet synchronization regardless of the package database’s age. This is unnecessary most of the time.

pacman -Syy: This command updates the package lists on the system. It synchronizes the local package database with the remote package repositories to ensure you have the latest version information. The extra “y” forces a refresh, even if the database is already up to date.

pacman -Syu: This command updates the system packages to their latest versions. It synchronizes the package database as in the previous command, but it also upgrades all installed packages on the system to the latest available versions. The “-u” option is used to update all packages that are out-of-date.

pacman -Syu updates the system packages along with the package lists.

Clean Paru/Pacman cache

  • https://discovery.endeavouros.com/articles/root-partition-full-dont-panic-clear-pacmans-cache-first/2020/03/
    • Same as Pacman command,but this also cleans out AUR packages
# Clear cache for uninstalled packages
paru -Sc

# Clean Paru/Pacman Cache for EVERY package
paru -Scc

# Clean cache without confirmation
# https://bbs.archlinux.org/viewtopic.php?id=236186
( echo "y"; echo "y" ) | sudo paru -Scc

Export packages to file / Install packages from file

# put all explicitly installed packages (minus AUR) into a file
# can be run as user
pacman -Qqe | grep -Fvx "$(pacman -Qqm)" > FILE

# get all installed packages including AUR
pacman -Qqe > /home/yuriy/Syncthing/Configurations/Pacman+Paru/$(hostname)_pacmanpkglist.txt

# Add to autostart script to automatically export whenever computer boots
/home/yuriy/Syncthing/Scripts/Bash/Tools/ExportPacmanpkglist.sh

# reinstall from said file (deps will be pulled in automatically)
# must run as root
sudo xargs paru -S --needed --noconfirm < FILE

Pacman is currently in use, please wait

  • Pacman is locked, usually due to a reboot in the middle of updating
sudo rm /var/lib/pacman/db.lck

Use pacman to find which package provides a file

# Update Database
pacman -Fy 

# Lookup package for file
pacman -F /usr/bin/qdbus 

Results: e0d24a0f0e4193b83bc743c068b810d2.png


Last updated on July 17, 2024. For any questions/feedback, email me at blog@zinchuk.xyz.