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:

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

    1
    
    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:

    1
    2
    
    git clone <repository-url>
    makepkg -si
    

Removing Packages

  • Remove a Specific Package:

    1
    
    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:

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

    1
    
    sudo pacman -Sc
    

Managing Package Lists

  • List All Installed Packages:

    1
    
    sudo pacman -Q
    
  • List Manually Installed Packages:

    1
    
    sudo pacman -Qe
    
  • List Installed AUR Packages:

    1
    
    sudo pacman -Qm
    
  • List Unneeded Dependencies:

    1
    
    sudo pacman -Qdt
    

Getting Started with Pacman

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

    1
    
    pacman -Qqen > pkglist.txt
    

    To reinstall packages from the list:

    1
    
    pacman -S - < pkglist.txt
    

Rollback to Previous Versions

  • List Cached Packages:

    1
    
    ls /var/cache/pacman/pkg/
    

    To downgrade a package:

    1
    
    sudo pacman -U <package-file>
    

Managing Mirror Lists

  • Edit and Refresh Mirror List:
    1
    2
    
    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:
    1
    
    sudo vim /etc/pacman.conf
    
    Then uncomment or add the following line to enable multiple simultaneous downloads:
    1
    
    ParallelDownloads=5
    
  • Ignore Specific Packages: Add the following line to /etc/pacman.conf to prevent specific packages from being updated:
    1
    
    IgnorePkg = postgresql*