[ Prev ] [ Index ] [ Next ]

Pacman

Created søndag 23 oktober 2016


Log files

# Pacman's output is logged to /var/log/pacman.log



Configuration file

# The pacman configuration can be found at /etc/pacman.conf


Skip package from being upgraded

# Add packages to the IgnorePkg= option.
# Additional packages can be added with a space-separated list.
# The same can be done for a group (Gnome ex.) with the IgnoreGroup= option.


32-bit libraries (multilib)

# Uncomment the multilib repository for 32-bit supported packages (Steam ex.)


A little extra sweetness

# Add colors to your pacman output, by outcommenting #Color in # Misc Options
# Outcomment VerbosePkgLists to get a more detailed package overview when upgrading the system
# Also, a little nice Easter Egg is the pacman (game) imitation. Add ILoveCandy to # Misc Options

Color
VerbosePkgLists
ILoveCandy



General Usage

# You can install a single or multiple packages
$ pacman -S package1 package2


# Check if package came with a service file
$ pacman -Qql <PACKAGE_NAME> | grep -Fe .service -e .socket


# Remove packages
$ pacman -Rs <PACKAGE_NAME> # -s = remove dependencies not needed by other packages too
$ pacman -Rn <PACKAGE_NAME> # -n = don't create a .pacsave file


# Upgrade system
$ pacman -Syyu


# Searching packages
$ pacman -Ss <SEARCH_CRITERIA> # Search in names and descriptions
$ pacman -Ss '^<SEARCH_CRITERIA>' # Search in names only
$ pacman -Qs <SEARCH_CRITERIA> # Search installed packages


# Extensive information about a package
$ pacman -Si <PACKAGE_NAME>
$ pacman -Qi <PACKAGE_NAME> # Installed packages


# List all installed packages (not dependecies)
$ pacman -Qet


# List dependency tree for a package
$ pactree <PACKAGE_NAME>


# List all packages depending on a package
$ pactree -r <PACKAGE_NAME>


# List all orphans
$ pacman -Qdt



Unofficial keys

# You can add a key as trusted to the pacman-key, in 3 simple steps.


# First read the key
$ pacman-key -r keyid # Key from a server
$ pacman-key --add /path/to/file # Provided key-file


# Verify it
$ pacman-key -f keyid


# Sign it
$ pacman-key --lsign-key keyid


# If you get a dirmngr ERROR, run the following
$ dirmngr < /dev/null



Tips and Tricks

# Some random Tips and Tricks


Packages changelog

# Update changes can be viewed by installing pacolog (AUR)
$ yaourt -S pacolog


# Invoke it with
$ pacolog <PACKAGE_NAME>


Save a list of installed packages

# You can save a list of installed packages and speed up installation of same packages
# on a fresh install. Create a list with
$ pacman -Qqen > pkglist.txt


# To install the packages from the newly created list
pacman -S < pkglist.txt


# If the list include AUR packages, remove these from the list first
$ pacman -S $(comm -12 <(pacman -Slq | sort) <(sort pkglist.txt))


Optimize database access speed

$ pacman -Sc && sudo pacman-optimize


Update notifier

# If you'd like to be notified when there's an update, you can install Kalu (AUR)
# Though, you can expect there to be updates pretty much every day^
$ yaourt -S kalu


Help the developers at Arch

# pkgstats sends a list of installed packages, kernels, architecture and mirrors you use (anonymous)
# to the Arch Linux developers. This is done once a week automatically.
$ pacman -S pkgstat



Hooks

# A hook is an action (or set of) to be run when pacman remove/upgrade/install is invoked.
# Hooks can be saved in /etc/pacman.d/hooks/ Below is a default hook file
# Hooks must be saved with the .hook extension

[Trigger]
Operation = 
Type = 
Target = 

[Action]
Description = 
When = 
Exec = 
Depends = 
AbortOnFail
NeedsTarget


# Triggers

|                                          | Description                             | Required/repeatable    |
|:-----------------------------------------|:----------------------------------------|:-----------------------|
| Operation = Install \| Upgrade \| Remove |                                         | # Required, Repeatable |
| Type = File \| Package                   | # Select Package                        | # Required             |
| Target = <path> \| <package>             | # Files in a directory or specific file | # Required, Repeatable |


# Actions

|                                          | Description                                                              | Required/repeatable |
|:-----------------------------------------|:-------------------------------------------------------------------------|:--------------------|
| Description =                            | # description for front-end view                                         |                     |
| Exec = <command>                         | # Command to run                                                         | # Required          |
| When = PreTransaction \| PostTransaction |                                                                          | # Required          |
| Depends = <package>                      | # Packages that must be installed for hook to run                        |                     |
| AbortOnFail                              | # Cancel the transaction if error occurs. Only works with PreTransaction |                     |
| NeedsTarget                              | # Pass along if Trigger.Target is set                                    |                     |



Useful Hooks

# Sync storage caches to reduce the risk of system corruption

[Trigger]
Operation = Install
Operation = Upgrade
Operation = Remove
Type = Package
Target = *

[Action]
Depends = coreutils
When = PostTransaction
Exec = /bin/sync



Troubleshoot

# A few troubleshoot examples


"Failed to commit transaction (conflicting files)" error :

error: could not prepare transaction
error: failed to commit transaction (conflicting files)
package: /path/to/file exists in filesystem
Errors occurred, no packages were upgraded.


# The above indicates a conflict in packages.
# To fix this, first check if the file is owned by another package
$ pacman -Qo /path/to/file


# If the file does not belong to any other package, it can be removed.
# If the file is owned, file a bug report.


"Failed to commit transaction (invalid or corrupted package)" error :

# Caused by partially downloaded packages (*.part) stored in /var/cache/pacman/pkg/
# Remove them with
$ find /var/cache/pacman/pkg/ -iname "*.part" -exec rm {} \;


"Failed to init transaction (unable to lock database)" error :

# Close all instances of pacman and run
$ rm /var/lib/pacman/db.lck


Key could not be looked up remotely

# Ex.

downloading required keys...
error: key "F22FB1D78A77AEAB" could not be looked up remotely
error: required key missing from keyring


# Problems with the Keyring can be solved by re-installing the keyring
$ pacman -Sy archlinux-keyring
$ pacman -Su