Terry : Arch Linux



Installing packages

Install specific packages

pacman -S package_name
pacman -S package_name1 packagename2

Install package groups

pacman -S gnome
# see packages belong to the group
pacman -Sg gnome

Removing package

pacman -R package_name
# remove a package and its dependencies which are not required by any other installed package
pacman -Rs package_name

# remove a package, its dependencies and all the packages that depend on the target package
pacman -Rsc package_name

# remove a package, which is required by another package, without removing the dependent package
pacman -Rdd package_name

# to prevent the creation of .pacsave backup files use the -n option
pacman -Rn package_name

Remove orphan packages

Equivalent to the following in Debian or Ubuntu.

deborphan | xargs apt-get purge -y

Listing real orphans - packages that were installed as dependencies but are no longer required by any installed package.

pacman -Qdt

Listing explicitly installed packages which are not required by any other package.

pacman -Qet

Upgrading packages

pacman -Syu
# Bypass confirmation (use only in script)
pacman -Syu --noconfirm
pacman -Syu --noc
# ignore a package / package group
pacman -Syu --ignore package1,package2,package3 --ignoregroup group1,group2

NOTE: pacman output -> /var/log/pacman.log

Querying the Package Databases

Local package database -> -Q

Sync package databases -> -S

Pacman can search for packages in the database, searching both in packages' names and descriptions:

# To search packages in the database, searching both in packages' names and descriptions
pacman -Ss string1 string2 ...

# To search for already installed packages
pacman -Qs string1 string2 ...

# To display extensive information about a given package
pacman -Si package_name

# For locally installed packages
pacman -Qi package_name

# Passing two -i flags will also display the list of backup files and their modification states
pacman -Qii package_name

# To retrieve a list of the files installed by a package
# For packages NOT installed use pkgfile
pacman -Ql package_name

# To verify the presence of the files installed by a package
pacman -Qk package_name
# Passing the k flag twice will perform a more thorough check

# Query the database to know which package a file in the file system belongs to
pacman -Qo /path/to/file_name
pacman -Qo $(which command)

# To list all packages no longer required as dependencies (orphans)
pacman -Qdt

# To list a dependency tree of a package
pactree package_name

Backing up and retrieving a list of installed packages


1. backup the current list of non-local packages

pacman -Qqen > pkglist.txt

2. Store the pkglist.txt on a USB key or other convenient medium or gist.github.com or Evernote, Dropbox, etc

 3. Copy the pkglist.txt file to the new installation, and navigate to the directory containing it

 4. Issue the following command to install from the backup list

pacman -S $(< pkglist.txt)

In the case you have a list which was not generated like mentioned above, there may be foreign packages in it (i.e. packages not belonging to any repos you have configured, or packages from the AUR).

In such a case, you may still want to install all available packages from that list

pacman -S --needed $(comm -12 <(pacman -Slq | sort) <(sort badpkdlist) )


  • pacman -Slq lists all available softwares, but the list is sorted by repository first, hence the sort command
  • Sorted files are required in order to make the comm command work
  • The -12 parameter display lines common to both entries
  • The --needed switch is used to skip already installed packages.

You may also try to install all unavailable packages (those not in the repos) from the AUR using yaourt (not recommended unless you know exactly what you are doing)

yaourt -S --needed $(comm -13 <(pacman -Slq | sort) <(sort badpkdlist) )

Finally, you may want to remove all the packages on your system that are not mentioned in the list.

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

Warning: Use this command wisely, and always check the result prompted by pacman.

Cleaning the package cache

pacman -Scc
pacman -Sc

NOTE: The paccache command, provided by the pacman package itself, by default deletes all the cached versions of each package except for the most recent 3: paccache -r

Additional commands

Download a package without installing it

pacman -Sw package

Install a local package

pacman -U /path/to/package.pkg.tar.xz
# Keep a copy of the local package in pacman package cache
pacman -U file://path/to/package/package_name-version.pkg.tar.xz

Tip: To keep a copy of the local package in pacman's cache, use the 2nd.


Listing installed packages with version

Get the list of installed packages with their version, which is useful when reporting bugs or discussing installed packages.

# List all explicitly installed packages
pacman -Qe

#List all foreign packages (typically manually downloaded and installed)
pacman -Qm

# List all native packages (installed from the sync database(s))
pacman -Qn

# List packages by regex
pacman -Qs <regex> | awk 'BEGIN { RS="\n" ; FS="/" } { print $2 }' | awk '{ if(NF > 0) print $1, $2 }'

# Install expac and run
expac -s "%-30n %v"

# List all packages with version and repo - Install yaourt and run
yaourt -Q

Removing orphaned packages

For recursively removing orphans and their configuration files

pacman -Rns $(pacman -Qtdq)

If no orphans were found, pacman errors with error: no targets specified. This is expected as no arguments were passed to pacman -Rns.

Listing changed configuration files

If you want to backup your system configuration files you could copy all files in /etc/, but usually you are only interested in the files that you have changed.

In this case you want to list those changed configuration files, we can do this with the following command

pacman -Qii | awk '/^MODIFIED/ {print $2}'


pacman tips

Color output

As of version 4.1, Pacman has a color option. Uncomment the "Color" line in pacman.conf.

# Misc options

Save and run pacman -Syu



pacman Tips




archlinuxguide.pdf (application/pdf)