Contents

Handy Pacman Commands in Arch Linux

Pacman, the package manager for Arch Linux, is known for its simple binary package format and easy-to-use build system. The primary aim of Pacman is to facilitate straightforward management of packages from both the official repositories and user-generated builds.

Pacman ensures your system remains updated by synchronizing the package lists with the master server. This client/server model simplifies the process of downloading and installing packages, along with all their dependencies, using basic commands.

Installing and Upgrading Packages

  • Install a Package:

    sudo pacman -S <package-name>
  • Full System Upgrade:

    sudo pacman -Syu
    • -y synchronizes the database, similar to sudo apt-get update.
    • -u upgrades all out-of-date packages, akin to sudo apt-get upgrade.
  • Installing Packages from Git: Clone the package and install:

    git clone <repository-url>
    makepkg -si

Removing Packages

  • Remove a Specific Package:

    sudo pacman -R <package-name>

    Using -s removes dependencies not required by other packages, but be cautious as it may affect dependencies needed by other programs.

  • Best Practice for Removing Packages:

    sudo pacman -Rns <package-name>
  • Remove Obsolete Packages:

    sudo pacman -Sc

Managing Package Lists

  • List All Installed Packages:

    sudo pacman -Q
  • List Manually Installed Packages:

    sudo pacman -Qe
  • List Installed AUR Packages:

    sudo pacman -Qm
  • List Unneeded Dependencies:

    sudo pacman -Qdt

Getting Started with Pacman

  • Creating a List of Installed Packages: Generate a list to easily reinstall packages on a new system:

    pacman -Qqen > pkglist.txt

    To reinstall packages from the list:

    pacman -S - < pkglist.txt

Rollback to Previous Versions

  • List Cached Packages:

    ls /var/cache/pacman/pkg/

    To downgrade a package:

    sudo pacman -U <package-file>

Managing Mirror Lists

  • Edit and Refresh Mirror List:
    sudo vim /etc/pacman.d/mirrorlist
    sudo pacman -Syy
    Use -yy to force a refresh of the package databases, even if they are up to date.

Configuration Tips

  • Enable Parallel Downloads: Open your configuration file:
    sudo vim /etc/pacman.conf
    Then uncomment or add the following line to enable multiple simultaneous downloads:
    ParallelDownloads=5
  • Ignore Specific Packages: Add the following line to /etc/pacman.conf to prevent specific packages from being updated:
    IgnorePkg = postgresql*