Skip to content

Instantly share code, notes, and snippets.

@imogenkinsman
Last active October 1, 2020 23:28
Show Gist options
  • Save imogenkinsman/edfdf354d4f4ea77df6da560afbd3875 to your computer and use it in GitHub Desktop.
Save imogenkinsman/edfdf354d4f4ea77df6da560afbd3875 to your computer and use it in GitHub Desktop.
How To Use Pacman

This is my first Arch install and I keep forgetting or using unsafe pacman commands, so I made a thing.

Arch's philosophy is to be modular, give you control over everything, and allow you to shoot yourself in the foot every other day until you run out of toes.

This guide is meant to be used as a quick reference and prioritizes safe, sane defaults, but you should read the pacman docs first. They're a quick read, and will save you some pain later.

Pacman and Aur

Pacman only works with official repos - unofficial repos are listed in aur, the Arch Linux Repository. It's common to use yay, a wrapper that allows you to easily use both aur and the official repository:

pacman -S --needed git base-devel
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

Once you have yay, you can use yay instead of pacman for all commands, kind of like npm and yarn.

Commands

install or update a package
pacman -S <package>
-S means "synchronize", and any command that uses it is hitting the remote server. When used alone, it synchronizes with the newest state of a remote package, effectively installing it if it's not installed.
By default, pacman will just reinstall any package you tell it to, even if it's already up to date. Use --needed if you want to prevent this.

delete package
pacman -Rs <package>
This recurvisely (-s flag) deletes the package and all dependencies that aren't required by other packages.

search for a package
pacman -Ss <string>

list all installed packages
pacman -Qqe
Consider cronning a bash script to update this remotely. It'll make things easier for when you inevitably hose your OS.

upgrade all packages
pacman -Syu
Run this regularly - I usually run it before syncing a new package. This upgrades all of your downloaded packages - including your operating system :D. There are some changes that require user intervention, so read the home page before running. Even better, subscribe to the RSS feed.

Problems?

Read the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment