yay -Sw $(paclist core extra community multilib blackarch chaotic-aur | awk '{print $1}')

PACKAGE SORTING


  • sort packages sizewise :

expac -s "%-30n %m" | sort -rhk 2 | less expac --timefmt='%Y-%m-%d %T' '%l\t%n %v' | sort | tail -200 | nl

PACKAGE MANAGEMENT


  • total official package number :

yay -Q | wc -l

  • total native package number :

yay -Qqn | wc -l

  • total unofficial package number :

yay -Qm | wc -l

  • all orphans packages :

pacman -Qdt | wc -l

  • saves all package names to file :

paclist core community extra multilib blackarch | awk '{print $1}' >> list.txt

  • list all (installed + uninstalled) packages from a specific repo :

pacman -Sl <repo>

  • list all packages explicitly installed and not required as dependencies :

pacman -Qet

  • list all the files owned by package :

pacman -Ql package_name

  • filter output to packages installed as dependencies of that packageme :

pacman -Qd package_name

  • check that all files owned by the given package(s) are present on the system :

sudo pacman -Qk | grep package_name

  • check that all files owned by the given package(s) are present on the system :

sudo pacman -Qkk | grep package_name

  • check if there is any package owns or not :

sudo pacman -Qo /usr/lib/python3.6/site-packages/requests/init_.py

  • create a list of explicitly installed packages in alphabetical order and save them in a text file :

pacman -Qqe > pkglist.txt

  • ignore packages in pacman update :

--ignore pkg1,pkg2,pkg3

  • install a local package, or from a website :

sudo pacman -U /path/to/the/package

  • draw the optional dependency tree :

pactree <package_name>

  • draw the optional dependency tree once :

pactree -u <package_name>

UNINSTALL PACKAGE


  • remove a package and its dependencies :

sudo pacman -Rns package_name

  • remove a package with its dependencies and the packages that rely on those dependencies :

sudo pacman -Rsc package_name

  • remove a package that is required by another package without removing the dependent package, use this command :

sudo pacman -Rdd package_name

  • remove all the packages on the newly installed system that are not mentioned in the backup list :

sudo pacman -Rsu $(comm -23 <(pacman -Qq | sort) <(sort pkglist.txt))

  • remove all orphan packages :

yay -Rns $(yay -Qtdq)

UPDATE SYSTEM


  • update the system :

sudo pacman -Syu

  • update all packages, then downgrade all affected packages :

sudo pacman -Suu

  • full system upgraded without any issues :

sudo pacman -Syyu

  • only download update :

sudo pacman -Syuw

  • update offline :

sudo pacman -Su

  • update the database :

sudo pacman -Syy

CACHE AND DATABASE MANAGEMENT


  • updating the system using different storage :

sudo pacman -Syu --cachedir /mnt

  • updating the system using different db and storage :

sudo pacman -Syu -b /mnt/var/lib/pacman/ --cachedir /mnt

  • delete all cached versions of installed and uninstalled packages except for the most recent 3 :

paccache -rvk3

  • remove all cached versions of uninstalled packages :

sudo paccache -ruk0

  • removes all previous versions :

sudo pacman -Sc

  • leave nothing in the cache :

pacman -Scc

PACKAGE SEARCH


  • search the string in the repo :

pacman -Ss

  • check what nvidia packages you have installed with pacman -Qs nvidia :

pacman -Qs

  • search the package if it’s installed or not :

pacman -Q

  • search the exact package in the repo :

pacman -Sii

  • search the exact package in the PC :

pacman -Qii

  • search for available updates :

pacman -Qu

  • retrieve a list of the files installed by a package :

pacman -Ql -Fl -Qk -Qkk

  • see what packages belong to the gnome group :

pacman -Sg gnome

  • search for package file names in remote packages :

pacman -Fs string1 string2

  • search locally for that file :

pacman -Fs file_name

REINSTALL ALL PACKAGES


  • only downloads repo packages :

paclist core community extra multilib blackarch | awk '{print $1}' | yay -Sw -

  • reinstalls all pacakages : paclist core community extra multilib blackarch | awk '{print $1}' | yay -S -

  • reinstalls all native packages :


sudo pacman -Qqn | pacman -S -

  • only downloads the offical packages :

yay -Sw $(pacman -Qqn)

  • install packages from a list :

sudo pacman -S --needed - < list.txt

  • install the package and it’s optional dependencies once :

sudo pacman -S $(pactree -u exfat-utils)

  • install packages from the backup list :

sudo pacman -S - < pkglist.txt

  • remove the foreign packages such as AUR packages :

sudo pacman -S $(comm -12 <(pacman -Slq | sort) <(sort pkglist.txt))


Manjaro wiki