Linux pacman Command: Manage Packages on Arch Linux

pacman manages packages and repositories in Arch Linux-based systems. It is important to perform installation, removal, repository synchronization, and full system upgrades in a single workflow.

What is the pacman command?

-S installs repository packages, -Q checks local installation status, and -R removes packages. -Syu synchronizes the package database and upgrades installed packages together. If you update only the database with -Sy and then install some packages, it can lead to a partial upgrade state, which should be avoided.

Basic syntax

pacman -operation[option] [package...]

The implemented features and options may vary depending on the distribution. Check your system's description with man pacman.

Examples

Searching repository packages

Check the name and description before installation.

pacman -Ss nginx

Checking installed package information

Look at the currently installed version and dependency information.

pacman -Qi bash

Full System Update

Run repository synchronization and a full package upgrade together, and review the list of changes.

sudo pacman -Syu

Local Package Query Result

pacman -Q queries installed local packages and their versions. In the following example, if bash is installed, one line will appear.

pacman -Q bash

Example output (versions vary by time):

bash 5.x.x-1

If there are no packages, the query fails and a non-zero exit status is returned. pacman -Syu combines repository synchronization with a full system upgrade. On Arch-based systems, performing partial upgrades by selectively upgrading only some packages can cause dependency issues, so follow the official operational guidelines.

Main Options and Format

Options/Format Description
-S package Install a package from the repository.
-Syu Perform database synchronization and full system upgrade together.
-Ss keyword Search for repository packages.
-Qi package Check the information of installed packages.
-R package Remove installed packages. Check the scope of additional options.

Precautions when using

In Arch, following the principle that partial upgrades are not supported, avoid flows where you run pacman -Sy alone and then install some packages. Before updating, check the distribution announcements and changelogs, and back up important data on older systems. Removal combinations like -Rns can clean up dependent packages and configuration more extensively, so always check the target list.

Frequently Asked Questions

How are pacman -Sy and -Syu different?

-Sy only synchronizes the repository database, while -Syu synchronizes and then updates all installed packages. Use -Syu for regular updates.

Official Documentation

The exact behavior of options and differences in implementation can be checked in the official pacman documentation.

More in This Category
Linux cmp Command: Compare Files Byte by Byte

Linux cmp Command: Compare Files Byte by Byte

Learn how Linux cmp compares two files byte by byte, reports the first mismatch, runs silently in scripts, limits ranges, and differs from diff and checksums.

Linux pgrep Command: Find Process IDs by Name or Criteria

Linux pgrep Command: Find Process IDs by Name or Criteria

Learn how to find Process IDs by Name or Criteria with the Linux pgrep command, including practical examples, key options, and important precautions.

Linux Tutorial / Inspect, Pause, and Stop Processes

Linux Tutorial / Inspect, Pause, and Stop Processes

Inspect Linux processes with ps, top, and pgrep, then safely pause, resume, and terminate a practice process while distinguishing shell jobs from services.

Linux env Command: Display Variables and Run Commands with a Custom Environment

Linux env Command: Display Variables and Run Commands with a Custom Environment

Learn how to use the Linux env command to display environment variables or run a command with temporary variable values, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux cp Command: Copy Files and Directories

Linux cp Command: Copy Files and Directories

Learn how to copy files and directories with Linux cp, control overwrites, preserve attributes, handle symlinks, and verify important copies.

Linux ss Command: Inspect Open Ports and Sockets

Linux ss Command: Inspect Open Ports and Sockets

Learn how to inspect Open Ports and Sockets with the Linux ss command, including practical examples, key options, and important precautions.

Linux w Command: Show Logged-In Users and Their Processes

Linux w Command: Show Logged-In Users and Their Processes

Learn how to show Logged-In Users and Their Processes with the Linux w command, including practical examples, key options, and important precautions.

Linux free Command: Check Memory and Swap Usage

Linux free Command: Check Memory and Swap Usage

Learn how to use the Linux free command to inspect available memory, used memory, cache, and swap usage, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux getent Command: Query Users, Groups, and Other NSS Databases

Linux getent Command: Query Users, Groups, and Other NSS Databases

Learn how to query Users, Groups, and Other NSS Databases with the Linux getent command, including practical examples, key options, and important precautions.

Linux csplit Command: Split Files at Lines or Patterns

Linux csplit Command: Split Files at Lines or Patterns

Learn how to split Files at Lines or Patterns with the Linux csplit command, including practical examples, key options, and important precautions.